From ee145ec9f6d622d1062979062a8a563cf8320d7b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 10 Nov 2016 16:28:37 -0800 Subject: [PATCH] Update LKG --- lib/lib.d.ts | 24 +- lib/lib.dom.d.ts | 24 +- lib/lib.es2017.d.ts | 3 +- lib/lib.es2017.string.d.ts | 47 + lib/lib.es6.d.ts | 24 +- lib/lib.webworker.d.ts | 2 + lib/tsc.js | 14199 +++++++++++++----------- lib/tsserver.js | 15691 +++++++++++++++------------ lib/tsserverlibrary.d.ts | 853 +- lib/tsserverlibrary.js | 15673 +++++++++++++++------------ lib/typescript.d.ts | 478 +- lib/typescript.js | 19683 +++++++++++++++++++--------------- lib/typescriptServices.d.ts | 478 +- lib/typescriptServices.js | 19683 +++++++++++++++++++--------------- lib/typingsInstaller.js | 706 +- 15 files changed, 48180 insertions(+), 39388 deletions(-) create mode 100644 lib/lib.es2017.string.d.ts diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 969bf70448c..4eb501c04d2 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -5836,6 +5836,7 @@ interface CSSStyleDeclaration { writingMode: string | null; zIndex: string | null; zoom: string | null; + resize: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -5905,6 +5906,7 @@ declare var CanvasGradient: { } interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; } declare var CanvasPattern: { @@ -6330,7 +6332,7 @@ interface DataTransfer { effectAllowed: string; readonly files: FileList; readonly items: DataTransferItemList; - readonly types: DOMStringList; + readonly types: string[]; clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; @@ -12759,7 +12761,7 @@ interface MouseEvent extends UIEvent { readonly x: number; readonly y: number; getModifierState(keyArg: string): boolean; - initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void; } declare var MouseEvent: { @@ -12872,6 +12874,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly plugins: PluginArray; readonly pointerEnabled: boolean; readonly webdriver: boolean; + readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; @@ -12889,18 +12892,18 @@ interface Node extends EventTarget { readonly attributes: NamedNodeMap; readonly baseURI: string | null; readonly childNodes: NodeList; - readonly firstChild: Node; - readonly lastChild: Node; + readonly firstChild: Node | null; + readonly lastChild: Node | null; readonly localName: string | null; readonly namespaceURI: string | null; - readonly nextSibling: Node; + readonly nextSibling: Node | null; readonly nodeName: string; readonly nodeType: number; nodeValue: string | null; readonly ownerDocument: Document; - readonly parentElement: HTMLElement; - readonly parentNode: Node; - readonly previousSibling: Node; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; textContent: string | null; appendChild(newChild: Node): Node; cloneNode(deep?: boolean): Node; @@ -17010,7 +17013,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly devicePixelRatio: number; readonly doNotTrack: string; readonly document: Document; - event: Event; + event: Event | undefined; readonly external: External; readonly frameElement: Element; readonly frames: Window; @@ -17312,6 +17315,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; + readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -18458,7 +18462,7 @@ declare var defaultStatus: string; declare var devicePixelRatio: number; declare var doNotTrack: string; declare var document: Document; -declare var event: Event; +declare var event: Event | undefined; declare var external: External; declare var frameElement: Element; declare var frames: Window; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index b80f167b7a8..217c7bf64d2 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -1699,6 +1699,7 @@ interface CSSStyleDeclaration { writingMode: string | null; zIndex: string | null; zoom: string | null; + resize: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -1768,6 +1769,7 @@ declare var CanvasGradient: { } interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; } declare var CanvasPattern: { @@ -2193,7 +2195,7 @@ interface DataTransfer { effectAllowed: string; readonly files: FileList; readonly items: DataTransferItemList; - readonly types: DOMStringList; + readonly types: string[]; clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; @@ -8622,7 +8624,7 @@ interface MouseEvent extends UIEvent { readonly x: number; readonly y: number; getModifierState(keyArg: string): boolean; - initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void; } declare var MouseEvent: { @@ -8735,6 +8737,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly plugins: PluginArray; readonly pointerEnabled: boolean; readonly webdriver: boolean; + readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; @@ -8752,18 +8755,18 @@ interface Node extends EventTarget { readonly attributes: NamedNodeMap; readonly baseURI: string | null; readonly childNodes: NodeList; - readonly firstChild: Node; - readonly lastChild: Node; + readonly firstChild: Node | null; + readonly lastChild: Node | null; readonly localName: string | null; readonly namespaceURI: string | null; - readonly nextSibling: Node; + readonly nextSibling: Node | null; readonly nodeName: string; readonly nodeType: number; nodeValue: string | null; readonly ownerDocument: Document; - readonly parentElement: HTMLElement; - readonly parentNode: Node; - readonly previousSibling: Node; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; textContent: string | null; appendChild(newChild: Node): Node; cloneNode(deep?: boolean): Node; @@ -12873,7 +12876,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly devicePixelRatio: number; readonly doNotTrack: string; readonly document: Document; - event: Event; + event: Event | undefined; readonly external: External; readonly frameElement: Element; readonly frames: Window; @@ -13175,6 +13178,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; + readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -14321,7 +14325,7 @@ declare var defaultStatus: string; declare var devicePixelRatio: number; declare var doNotTrack: string; declare var document: Document; -declare var event: Event; +declare var event: Event | undefined; declare var external: External; declare var frameElement: Element; declare var frames: Window; diff --git a/lib/lib.es2017.d.ts b/lib/lib.es2017.d.ts index 8354de37f7f..94c75a1b49e 100644 --- a/lib/lib.es2017.d.ts +++ b/lib/lib.es2017.d.ts @@ -20,4 +20,5 @@ and limitations under the License. /// /// -/// \ No newline at end of file +/// +/// diff --git a/lib/lib.es2017.string.d.ts b/lib/lib.es2017.string.d.ts new file mode 100644 index 00000000000..d82def20ece --- /dev/null +++ b/lib/lib.es2017.string.d.ts @@ -0,0 +1,47 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + + +/// + + +interface String { + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padStart(maxLength: number, fillString?: string): string; + + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padEnd(maxLength: number, fillString?: string): string; +} diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index f9eac9c02f0..360407234f6 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -7555,6 +7555,7 @@ interface CSSStyleDeclaration { writingMode: string | null; zIndex: string | null; zoom: string | null; + resize: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; item(index: number): string; @@ -7624,6 +7625,7 @@ declare var CanvasGradient: { } interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; } declare var CanvasPattern: { @@ -8049,7 +8051,7 @@ interface DataTransfer { effectAllowed: string; readonly files: FileList; readonly items: DataTransferItemList; - readonly types: DOMStringList; + readonly types: string[]; clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; @@ -14478,7 +14480,7 @@ interface MouseEvent extends UIEvent { readonly x: number; readonly y: number; getModifierState(keyArg: string): boolean; - initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; + initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget | null): void; } declare var MouseEvent: { @@ -14591,6 +14593,7 @@ interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorConte readonly plugins: PluginArray; readonly pointerEnabled: boolean; readonly webdriver: boolean; + readonly hardwareConcurrency: number; getGamepads(): Gamepad[]; javaEnabled(): boolean; msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; @@ -14608,18 +14611,18 @@ interface Node extends EventTarget { readonly attributes: NamedNodeMap; readonly baseURI: string | null; readonly childNodes: NodeList; - readonly firstChild: Node; - readonly lastChild: Node; + readonly firstChild: Node | null; + readonly lastChild: Node | null; readonly localName: string | null; readonly namespaceURI: string | null; - readonly nextSibling: Node; + readonly nextSibling: Node | null; readonly nodeName: string; readonly nodeType: number; nodeValue: string | null; readonly ownerDocument: Document; - readonly parentElement: HTMLElement; - readonly parentNode: Node; - readonly previousSibling: Node; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; textContent: string | null; appendChild(newChild: Node): Node; cloneNode(deep?: boolean): Node; @@ -18729,7 +18732,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly devicePixelRatio: number; readonly doNotTrack: string; readonly document: Document; - event: Event; + event: Event | undefined; readonly external: External; readonly frameElement: Element; readonly frames: Window; @@ -19031,6 +19034,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; + readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -20177,7 +20181,7 @@ declare var defaultStatus: string; declare var devicePixelRatio: number; declare var doNotTrack: string; declare var document: Document; -declare var event: Event; +declare var event: Event | undefined; declare var external: External; declare var frameElement: Element; declare var frames: Window; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 53129567256..cef348959e2 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -760,6 +760,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly upload: XMLHttpRequestUpload; withCredentials: boolean; msCaching?: string; + readonly responseURL: string; abort(): void; getAllResponseHeaders(): string; getResponseHeader(header: string): string | null; @@ -922,6 +923,7 @@ declare var WorkerLocation: { } interface WorkerNavigator extends Object, NavigatorID, NavigatorOnLine { + readonly hardwareConcurrency: number; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } diff --git a/lib/tsc.js b/lib/tsc.js index 65874dbea2b..5c1cd259757 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -61,6 +61,15 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(ts.Extension || (ts.Extension = {})); + var Extension = ts.Extension; })(ts || (ts = {})); var ts; (function (ts) { @@ -199,6 +208,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; function every(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -458,20 +474,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -547,6 +568,26 @@ var ts; return result || array; } ts.compact = compact; + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1: break inner; + case 0: continue outer; + case 1: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -556,15 +597,23 @@ var ts; return result; } ts.sum = sum; + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -583,6 +632,12 @@ var ts; : undefined; } ts.firstOrUndefined = firstOrUndefined; + function lastOrUndefined(array) { + return array && array.length > 0 + ? array[array.length - 1] + : undefined; + } + ts.lastOrUndefined = lastOrUndefined; function singleOrUndefined(array) { return array && array.length === 1 ? array[0] @@ -595,23 +650,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; - } - ts.lastOrUndefined = lastOrUndefined; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; return result; } ts.replaceElement = replaceElement; - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -1369,6 +1418,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -1396,68 +1449,83 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + if (component.charCodeAt(0) === 42) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -1524,25 +1592,30 @@ var ts; for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) { var include = includes_1[_i]; var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); } - basePaths.push(includeBasePath); + }; + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { return (scriptKind || getScriptKindFromFileName(fileName)) || 3; } @@ -1642,10 +1715,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -1791,6 +1860,30 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2085,6 +2178,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -2094,7 +2188,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -2102,7 +2196,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -2117,7 +2211,7 @@ var ts; watchDirectory: function (directoryName, callback, recursive) { var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -2314,7 +2408,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -2541,14 +2635,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -2588,7 +2682,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -2626,8 +2720,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2639,7 +2731,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2661,9 +2753,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -2710,6 +2800,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2733,6 +2830,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -2764,6 +2862,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2863,6 +2964,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -2946,7 +3048,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -2983,11 +3085,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2996,7 +3103,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -3053,6 +3161,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); var ts; @@ -3085,7 +3194,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3095,34 +3204,35 @@ var ts; "instanceof": 92, "interface": 108, "is": 125, + "keyof": 126, "let": 109, - "module": 126, - "namespace": 127, - "never": 128, + "module": 127, + "namespace": 128, + "never": 129, "new": 93, "null": 94, - "number": 131, + "number": 132, "package": 110, "private": 111, "protected": 112, "public": 113, - "readonly": 129, - "require": 130, - "global": 138, + "readonly": 130, + "require": 131, + "global": 139, "return": 95, - "set": 132, + "set": 133, "static": 114, - "string": 133, + "string": 134, "super": 96, "switch": 97, - "symbol": 134, + "symbol": 135, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 135, + "type": 136, "typeof": 102, - "undefined": 136, + "undefined": 137, "var": 103, "void": 104, "while": 105, @@ -3130,7 +3240,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -4517,9 +4627,9 @@ var ts; pos++; return token = 22; } - if (isIdentifierStart(ch, 4)) { + if (isIdentifierStart(ch, 5)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } return token = 70; @@ -4679,7 +4789,9 @@ var ts; } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -4705,21 +4817,21 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 2097152) !== 0; + return (node.flags & 4194304) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || + if (!(node.flags & 8388608)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; + node.flags |= 4194304; } - node.flags |= 4194304; + node.flags |= 8388608; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { + while (node && node.kind !== 260) { node = node.parent; } return node; @@ -4727,11 +4839,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: return true; } return false; @@ -4796,18 +4908,18 @@ var ts; if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { return getTokenPosOfNode(node.jsDocComments[0]); } - if (node.kind === 286 && node._children.length > 0) { + if (node.kind === 290 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 257 && node.kind <= 282; + return node.kind >= 261 && node.kind <= 286; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + return node.kind >= 277 && node.kind <= 289; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -4901,11 +5013,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 219 && node.parent.kind === 252; + return node.kind === 222 && node.parent.kind === 255; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 && + return node && node.kind === 229 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -4914,11 +5026,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); + return node.kind === 229 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || + return node.kind === 260 || + node.kind === 229 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -4931,9 +5043,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256: + case 260: return ts.isExternalModule(node.parent); - case 227: + case 230: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -4941,22 +5053,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { - case 256: - case 228: - case 252: - case 226: - case 207: - case 208: - case 209: - case 149: - case 148: + case 260: + case 231: + case 255: + case 229: + case 210: + case 211: + case 212: case 150: + case 149: case 151: - case 221: - case 180: - case 181: + case 152: + case 224: + case 183: + case 184: return true; - case 200: + case 203: return parentNode && !isFunctionLike(parentNode); } return false; @@ -4976,12 +5088,42 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70: + return name.text; + case 9: + case 8: + return name.text; + case 142: + if (isStringOrNumericLiteral(name.expression.kind)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70: + return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); + case 141: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 176: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { var span = getErrorSpanForNode(sourceFile, node); return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } - ts.createDiagnosticForNode = createDiagnosticForNode; + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -5004,7 +5146,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200) { + if (node.body && node.body.kind === 203) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5016,29 +5158,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256: + case 260: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 219: - case 170: case 222: - case 193: - case 223: - case 226: + case 173: case 225: - case 255: - case 221: - case 180: - case 148: - case 150: - case 151: + case 196: + case 226: + case 229: + case 228: + case 259: case 224: + case 183: + case 149: + case 151: + case 152: + case 227: errorNode = node.name; break; - case 181: + case 184: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5059,7 +5201,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); + return node.kind === 228 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5072,11 +5214,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; + return n.kind === 178 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; + return node.kind === 206 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -5092,10 +5234,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 || - node.kind === 142 || - node.kind === 180 || - node.kind === 181) ? + var commentRanges = (node.kind === 144 || + node.kind === 143 || + node.kind === 183 || + node.kind === 184) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -5110,69 +5252,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (155 <= node.kind && node.kind <= 167) { + if (156 <= node.kind && node.kind <= 170) { return true; } switch (node.kind) { case 118: - case 131: - case 133: - case 121: + case 132: case 134: - case 136: - case 128: + case 121: + case 135: + case 137: + case 129: return true; case 104: - return node.parent.kind !== 184; - case 195: + return node.parent.kind !== 187; + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 140 && node.parent.right === node) { + if (node.parent.kind === 141 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 173 && node.parent.name === node) { + else if (node.parent.kind === 176 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 140: - case 173: + ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 176, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 176: case 98: var parent_1 = node.parent; - if (parent_1.kind === 159) { + if (parent_1.kind === 160) { return false; } - if (155 <= parent_1.kind && parent_1.kind <= 167) { + if (156 <= parent_1.kind && parent_1.kind <= 170) { return true; } switch (parent_1.kind) { - case 195: + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 142: - return node === parent_1.constraint; - case 146: - case 145: case 143: - case 219: + return node === parent_1.constraint; + case 147: + case 146: + case 144: + case 222: return node === parent_1.type; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: + case 150: case 149: case 148: - case 147: - case 150: case 151: - return node === parent_1.type; case 152: + return node === parent_1.type; case 153: case 154: + case 155: + return node === parent_1.type; + case 181: return node === parent_1.type; case 178: - return node === parent_1.type; - case 175: - case 176: + case 179: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177: + case 180: return false; } } @@ -5183,23 +5325,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212: + case 215: return visitor(node); - case 228: - case 200: - case 204: - case 205: - case 206: + case 231: + case 203: case 207: case 208: case 209: - case 213: - case 214: - case 249: - case 250: - case 215: + case 210: + case 211: + case 212: + case 216: case 217: case 252: + case 253: + case 218: + case 220: + case 255: return ts.forEachChild(node, traverse); } } @@ -5209,23 +5351,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 194: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225: - case 223: + case 228: case 226: - case 224: - case 222: - case 193: + case 229: + case 227: + case 225: + case 196: return; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 141) { + if (name_5 && name_5.kind === 142) { traverse(name_5.expression); return; } @@ -5240,14 +5382,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170: - case 255: - case 143: - case 253: + case 173: + case 259: + case 144: + case 256: + case 147: case 146: - case 145: - case 254: - case 219: + case 257: + case 222: return true; } } @@ -5255,11 +5397,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 150 || node.kind === 151); + return node && (node.kind === 151 || node.kind === 152); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 222 || node.kind === 193); + return node && (node.kind === 225 || node.kind === 196); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5268,19 +5410,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 149: - case 180: - case 221: - case 181: - case 148: - case 147: case 150: + case 183: + case 224: + case 184: + case 149: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return true; } return false; @@ -5288,13 +5430,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 180: + case 152: + case 224: + case 183: return true; } return false; @@ -5302,30 +5444,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207: + case 210: + case 211: + case 212: case 208: case 209: - case 205: - case 206: return true; - case 215: + case 218: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 200 && isFunctionLike(node.parent); + return node && node.kind === 203 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 148 && node.parent.kind === 172; + return node && node.kind === 149 && node.parent.kind === 175; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 && - (node.parent.kind === 172 || - node.parent.kind === 193); + return node.kind === 149 && + (node.parent.kind === 175 || + node.parent.kind === 196); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5361,39 +5503,39 @@ var ts; return undefined; } switch (node.kind) { - case 141: + case 142: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 181: + case 184: if (!includeArrowFunctions) { continue; } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: + case 224: + case 183: + case 229: case 147: + case 146: case 149: + case 148: case 150: case 151: case 152: case 153: case 154: - case 225: - case 256: + case 155: + case 228: + case 260: return node; } } @@ -5406,25 +5548,25 @@ var ts; return node; } switch (node.kind) { - case 141: + case 142: node = node.parent; break; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: if (!stopOnFunctions) { continue; } - case 146: - case 145: - case 148: case 147: + case 146: case 149: + case 148: case 150: case 151: + case 152: return node; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5436,14 +5578,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { + if (func.kind === 183 || func.kind === 184) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179) { + while (parent_2.kind === 182) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 && parent_2.expression === prev) { + if (parent_2.kind === 178 && parent_2.expression === prev) { return parent_2; } } @@ -5451,32 +5593,32 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 || kind === 174) + return (kind === 176 || kind === 177) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 156: - return node.typeName; - case 195: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 70: - case 140: - return node; - } + switch (node.kind) { + case 157: + case 271: + return node.typeName; + case 198: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70: + case 141: + return node; } return undefined; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 175: - case 176: - case 177: - case 144: + case 178: + case 179: + case 180: + case 145: return true; default: return false; @@ -5484,7 +5626,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177) { + if (node.kind === 180) { return node.tag; } return node.expression; @@ -5492,21 +5634,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222: + case 225: return true; - case 146: - return node.parent.kind === 222; - case 150: + case 147: + return node.parent.kind === 225; case 151: - case 148: + case 152: + case 149: return node.body !== undefined - && node.parent.kind === 222; - case 143: + && node.parent.kind === 225; + case 144: return node.parent.body !== undefined - && (node.parent.kind === 149 - || node.parent.kind === 148 - || node.parent.kind === 151) - && node.parent.parent.kind === 222; + && (node.parent.kind === 150 + || node.parent.kind === 149 + || node.parent.kind === 152) + && node.parent.parent.kind === 225; } return false; } @@ -5522,19 +5664,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222: + case 225: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148: - case 151: + case 149: + case 152: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 244 || - parent.kind === 243 || - parent.kind === 245) { + if (parent.kind === 247 || + parent.kind === 246 || + parent.kind === 248) { return parent.tagName === node; } return false; @@ -5548,43 +5690,43 @@ var ts; case 100: case 85: case 11: - case 171: - case 172: - case 173: case 174: case 175: case 176: case 177: - case 196: case 178: - case 197: case 179: case 180: - case 193: + case 199: case 181: - case 184: + case 200: case 182: case 183: - case 186: + case 196: + case 184: case 187: - case 188: - case 189: - case 192: - case 190: - case 12: - case 194: - case 242: - case 243: - case 191: case 185: + case 186: + case 189: + case 190: + case 191: + case 192: + case 195: + case 193: + case 12: + case 197: + case 245: + case 246: + case 194: + case 188: return true; - case 140: - while (node.parent.kind === 140) { + case 141: + while (node.parent.kind === 141) { node = node.parent; } - return node.parent.kind === 159 || isJSXTagName(node); + return node.parent.kind === 160 || isJSXTagName(node); case 70: - if (node.parent.kind === 159 || isJSXTagName(node)) { + if (node.parent.kind === 160 || isJSXTagName(node)) { return true; } case 8: @@ -5592,47 +5734,47 @@ var ts; case 98: var parent_3 = node.parent; switch (parent_3.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 255: - case 253: - case 170: + case 259: + case 256: + case 173: return parent_3.initializer === node; - case 203: - case 204: - case 205: case 206: - case 212: - case 213: - case 214: - case 249: - case 216: - case 214: - return parent_3.expression === node; case 207: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || - forStatement.condition === node || - forStatement.incrementor === node; case 208: case 209: + case 215: + case 216: + case 217: + case 252: + case 219: + case 217: + return parent_3.expression === node; + case 210: + var forStatement = parent_3; + return (forStatement.initializer === node && forStatement.initializer.kind !== 223) || + forStatement.condition === node || + forStatement.incrementor === node; + case 211: + case 212: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 223) || forInStatement.expression === node; - case 178: - case 196: + case 181: + case 199: return node === parent_3.expression; - case 198: + case 201: return node === parent_3.expression; - case 141: + case 142: return node === parent_3.expression; - case 144: - case 248: - case 247: + case 145: + case 251: + case 250: return true; - case 195: + case 198: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -5650,7 +5792,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; + return node.kind === 233 && node.moduleReference.kind === 244; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5659,7 +5801,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; + return node.kind === 233 && node.moduleReference.kind !== 244; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5667,11 +5809,11 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); + return node && !!(node.flags & 2097152); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 175 && + var isRequire = expression.kind === 178 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -5683,9 +5825,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + if (s.valueDeclaration && s.valueDeclaration.kind === 222) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; + return declaration.initializer && declaration.initializer.kind === 183; } return false; } @@ -5694,11 +5836,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 188) { + if (expression.kind !== 191) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 176) { return 0; } var lhs = expr.left; @@ -5714,7 +5856,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 173) { + else if (lhs.expression.kind === 176) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -5730,35 +5872,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231) { + if (node.kind === 234) { return node.moduleSpecifier; } - if (node.kind === 230) { + if (node.kind === 233) { var reference = node.moduleReference; - if (reference.kind === 241) { + if (reference.kind === 244) { return reference.expression; } } - if (node.kind === 237) { + if (node.kind === 240) { return node.moduleSpecifier; } - if (node.kind === 226 && node.name.kind === 9) { + if (node.kind === 229 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 236) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 + return node.kind === 234 && node.importClause && !!node.importClause.name; } @@ -5766,13 +5908,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143: + case 144: + case 149: case 148: + case 257: + case 256: case 147: - case 254: - case 253: case 146: - case 145: return node.questionToken !== undefined; } } @@ -5780,9 +5922,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 && + return node.kind === 273 && node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + node.parameters[0].type.kind === 275; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -5833,32 +5975,32 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 201; + node.parent.parent.parent.kind === 204; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; + node.parent.parent.kind === 204; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 226 && - node.parent && node.parent.kind === 226) { + if (node.kind === 229 && + node.parent && node.parent.kind === 229) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 188 && + parent_4.kind === 191 && parent_4.operatorToken.kind === 57 && - parent_4.parent.kind === 203; + parent_4.parent.kind === 206; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 253; + var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 256; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 143) { + if (node.kind === 144) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -5883,14 +6025,14 @@ var ts; var tags = getJSDocTags(func, checkParentVariableStatement); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_6 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_6; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -5900,15 +6042,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + return getJSDocTag(node, 281, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + return getJSDocTag(node, 280, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + return getJSDocTag(node, 282, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -5920,7 +6062,7 @@ var ts; } for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { + if (tag.kind === 279) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -5940,13 +6082,13 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { + if (node && (node.flags & 2097152)) { + if (node.type && node.type.kind === 274) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; + return paramTag.typeExpression.type.kind === 274; } } return isDeclaredRestParam(node); @@ -5956,27 +6098,44 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 179) { - node = node.parent; - } + function getAssignmentTargetKind(node) { + var parent = node.parent; while (true) { - var parent_5 = node.parent; - if (parent_5.kind === 171 || parent_5.kind === 192) { - node = parent_5; - continue; + switch (parent.kind) { + case 191: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 189: + case 190: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 211: + case 212: + return parent.initializer === node ? 1 : 0; + case 182: + case 174: + case 195: + node = parent; + break; + case 257: + if (parent.name !== node) { + return 0; + } + case 256: + node = parent.parent; + break; + default: + return 0; } - if (parent_5.kind === 253 || parent_5.kind === 254) { - node = parent_5.parent; - continue; - } - return parent_5.kind === 188 && - isAssignmentOperator(parent_5.operatorToken.kind) && - parent_5.left === node || - (parent_5.kind === 208 || parent_5.kind === 209) && - parent_5.initializer === node; + parent = node.parent; } } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } ts.isAssignmentTarget = isAssignmentTarget; function isNodeDescendantOf(node, ancestor) { while (node) { @@ -5989,7 +6148,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 260 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6002,7 +6161,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { + if (parent.kind === 238 || parent.kind === 242) { if (parent.propertyName) { return true; } @@ -6015,48 +6174,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 141 && + node.parent.kind === 142 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 146: - case 145: - case 148: case 147: - case 150: + case 146: + case 149: + case 148: case 151: - case 255: - case 253: - case 173: + case 152: + case 259: + case 256: + case 176: return parent.name === node; - case 140: + case 141: if (parent.right === node) { - while (parent.kind === 140) { + while (parent.kind === 141) { parent = parent.parent; } - return parent.kind === 159; + return parent.kind === 160; } return false; - case 170: - case 235: + case 173: + case 238: return parent.propertyName === node; - case 239: + case 242: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 230 || - node.kind === 229 || - node.kind === 232 && !!node.name || - node.kind === 233 || - node.kind === 235 || - node.kind === 239 || - node.kind === 236 && exportAssignmentIsAlias(node); + return node.kind === 233 || + node.kind === 232 || + node.kind === 235 && !!node.name || + node.kind === 236 || + node.kind === 238 || + node.kind === 242 || + node.kind === 239 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6142,7 +6301,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 139; + return 71 <= token && token <= 140; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -6162,7 +6321,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 && + return name.kind === 142 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6172,10 +6331,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { return name.text; } - if (name.kind === 141) { + if (name.kind === 142) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6211,7 +6370,7 @@ var ts; case 113: case 111: case 112: - case 129: + case 130: case 114: return true; } @@ -6220,11 +6379,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 143; + return root.kind === 144; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 170) { + while (node.kind === 173) { node = node.parent.parent; } return node; @@ -6232,15 +6391,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 149 - || kind === 180 - || kind === 221 - || kind === 181 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 183 + || kind === 224 + || kind === 184 + || kind === 149 || kind === 151 - || kind === 226 - || kind === 256; + || kind === 152 + || kind === 229 + || kind === 260; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6248,13 +6407,13 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { + function getOriginalNode(node, nodeTest) { if (node) { while (node.original !== undefined) { node = node.original; } } - return node; + return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; function isParseTreeNode(node) { @@ -6291,23 +6450,23 @@ var ts; ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176: + case 179: return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: case 189: - case 191: - return 1; + case 186: + case 187: + case 185: case 188: + case 192: + case 194: + return 1; + case 191: switch (operator) { case 39: case 57: @@ -6331,15 +6490,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188) { + if (expression.kind === 191) { return expression.operatorToken.kind; } - else if (expression.kind === 186 || expression.kind === 187) { + else if (expression.kind === 189 || expression.kind === 190) { return expression.operator; } else { @@ -6357,36 +6516,36 @@ var ts; case 85: case 8: case 9: - case 171: - case 172: - case 180: - case 181: - case 193: - case 242: - case 243: - case 11: - case 12: - case 190: - case 179: - case 194: - return 19; - case 177: - case 173: case 174: - return 18; - case 176: - return hasArguments ? 18 : 17; case 175: - return 17; - case 187: - return 16; - case 186: case 183: case 184: + case 196: + case 245: + case 246: + case 11: + case 12: + case 193: case 182: + case 197: + return 19; + case 180: + case 176: + case 177: + return 18; + case 179: + return hasArguments ? 18 : 17; + case 178: + return 17; + case 190: + return 16; + case 189: + case 186: + case 187: case 185: - return 15; case 188: + return 15; + case 191: switch (operatorKind) { case 50: case 51: @@ -6444,11 +6603,11 @@ var ts; default: return -1; } - case 189: - return 4; - case 191: - return 2; case 192: + return 4; + case 194: + return 2; + case 195: return 1; default: return -1; @@ -6694,13 +6853,16 @@ var ts; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); + var sourceFiles = getAllEmittableSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; return ts.filter(sourceFiles, isNonDeclarationFile); } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } } ts.getSourceFilesToEmit = getSourceFilesToEmit; function isNonDeclarationFile(sourceFile) { @@ -6758,7 +6920,7 @@ var ts; onBundledEmit(host); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { @@ -6788,7 +6950,7 @@ var ts; action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || !!ts.getEmitModuleKind(options)); }); @@ -6828,7 +6990,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 149 && nodeIsPresent(member.body)) { + if (member.kind === 150 && nodeIsPresent(member.body)) { return member; } }); @@ -6869,10 +7031,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 150) { + if (accessor.kind === 151) { getAccessor = accessor; } - else if (accessor.kind === 151) { + else if (accessor.kind === 152) { setAccessor = accessor; } else { @@ -6881,7 +7043,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 150 || member.kind === 151) + if ((member.kind === 151 || member.kind === 152) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6892,10 +7054,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 150 && !getAccessor) { + if (member.kind === 151 && !getAccessor) { getAccessor = member; } - if (member.kind === 151 && !setAccessor) { + if (member.kind === 152 && !setAccessor) { setAccessor = member; } } @@ -7097,7 +7259,7 @@ var ts; case 75: return 2048; case 78: return 512; case 119: return 256; - case 129: return 64; + case 130: return 64; } return 0; } @@ -7113,19 +7275,25 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && + if (node.kind === 198 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node) { + return isBinaryExpression(node) + && isAssignmentOperator(node.operatorToken.kind) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 172 - || kind === 171; + return kind === 175 + || kind === 174; } } return false; @@ -7152,20 +7320,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 173 && isEntityNameExpression(node.expression); + node.kind === 176 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 140 && node.parent.right === node) || - (node.parent.kind === 173 && node.parent.name === node); + return (node.parent.kind === 141 && node.parent.right === node) || + (node.parent.kind === 176 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172) { + if (kind === 175) { return expression.properties.length === 0; } - if (kind === 171) { + if (kind === 174) { return expression.elements.length === 0; } return false; @@ -7299,39 +7467,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 173) { + else if (kind === 176) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174) { + else if (kind === 177) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 - || kind === 187) { + else if (kind === 189 + || kind === 190) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188) { + else if (kind === 191) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189) { + else if (kind === 192) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 184 - || kind === 183 - || kind === 182) { + else if (kind === 187 + || kind === 186 + || kind === 185) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171) { + else if (kind === 174) { return node.elements.length === 0; } - else if (kind === 172) { + else if (kind === 175) { return node.properties.length === 0; } - else if (kind === 175) { + else if (kind === 178) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7437,23 +7605,26 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile, resolver) { var externalImports = []; var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 231: + case 234: externalImports.push(node); break; - case 230: - if (node.moduleReference.kind === 241) { + case 233: + if (node.moduleReference.kind === 244) { externalImports.push(node); } break; - case 237: + case 240: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -7466,21 +7637,102 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_8 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_8] || (exportSpecifiers[name_8] = [])).push(specifier); + if (!uniqueExports[specifier.name.text]) { + var name_8 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_8.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_8) + || resolver.getReferencedValueDeclaration(name_8); + if (decl) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = specifier.name; + } } } break; - case 236: + case 239: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; + case 204: + if (hasModifier(node, 1)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + collectExportedVariableInfo(decl, uniqueExports); + } + } + break; + case 224: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_9 = node.name; + if (!uniqueExports[name_9.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_9); + uniqueExports[name_9.text] = name_9; + } + } + } + break; + case 225: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_10 = node.name; + if (!uniqueExports[name_10.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_10); + uniqueExports[name_10.text] = name_10; + } + } + } + break; } } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + var exportedNames; + for (var key in uniqueExports) { + exportedNames = ts.append(exportedNames, uniqueExports[key]); + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; } ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports) { + if (isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!isOmittedExpression(element)) { + collectExportedVariableInfo(element, uniqueExports); + } + } + } + else if (!isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = decl.name; + } + } + } + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 228: + case 229: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -7492,7 +7744,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && declaration !== node) { + if (declaration.kind === 225 && declaration !== node) { return true; } } @@ -7552,16 +7804,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 140 + return kind === 141 || kind === 70; } ts.isEntityName = isEntityName; @@ -7570,7 +7822,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 141; + || kind === 142; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -7582,57 +7834,58 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 168 - || kind === 169; + || kind === 171 + || kind === 172; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 144; + return node.kind === 145; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 148; + return node.kind === 149; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 149 - || kind === 146 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 147 + || kind === 149 || kind === 151 - || kind === 154 - || kind === 199; + || kind === 152 + || kind === 155 + || kind === 202; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 + return kind === 256 + || kind === 257 + || kind === 258 + || kind === 149 || kind === 151 - || kind === 240; + || kind === 152 + || kind === 243; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) + return (kind >= 156 && kind <= 170) || kind === 118 - || kind === 131 + || kind === 132 || kind === 121 - || kind === 133 || kind === 134 + || kind === 135 || kind === 104 - || kind === 128 - || kind === 195; + || kind === 129 + || kind === 198; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -7641,94 +7894,102 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 - || kind === 168; + return kind === 172 + || kind === 171; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170; + return node.kind === 173; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 - || kind === 194; + return kind === 173 + || kind === 197; } ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 174; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 175; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173; + return node.kind === 176; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174; + return node.kind === 177; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188; + return node.kind === 191; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189; + return node.kind === 192; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175; + return node.kind === 178; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 + return kind === 193 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { + function isSpreadExpression(node) { return node.kind === 195; } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 198; + } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 + return kind === 176 || kind === 177 - || kind === 171 || kind === 179 - || kind === 172 - || kind === 193 + || kind === 178 + || kind === 245 + || kind === 246 || kind === 180 + || kind === 174 + || kind === 182 + || kind === 175 + || kind === 196 + || kind === 183 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 190 + || kind === 193 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 197; + || kind === 200; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 - || kind === 187 - || kind === 182 - || kind === 183 - || kind === 184 + return kind === 189 + || kind === 190 || kind === 185 - || kind === 178 + || kind === 186 + || kind === 187 + || kind === 188 + || kind === 181 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -7736,13 +7997,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 - || kind === 192 - || kind === 196 + return kind === 192 || kind === 194 + || kind === 184 + || kind === 191 + || kind === 195 + || kind === 199 + || kind === 197 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -7751,16 +8012,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 - || kind === 196; + return kind === 181 + || kind === 199; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288; + return node.kind === 292; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287; + return node.kind === 291; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -7769,15 +8030,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194; + return node.kind === 197; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 198; + return node.kind === 201; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 200; + return node.kind === 203; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -7795,119 +8056,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219; + return node.kind === 222; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220; + return node.kind === 223; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228; + return node.kind === 231; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 - || kind === 226; + return kind === 230 + || kind === 229; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230; + return node.kind === 233; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232; + return node.kind === 235; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 - || kind === 233; + return kind === 237 + || kind === 236; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235; + return node.kind === 238; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238; + return node.kind === 241; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239; + return node.kind === 242; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; + return node.kind === 229 || node.kind === 228; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 + return kind === 184 + || kind === 173 || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 + || kind === 196 || kind === 150 - || kind === 232 - || kind === 230 - || kind === 235 - || kind === 223 - || kind === 148 - || kind === 147 - || kind === 226 - || kind === 229 - || kind === 233 - || kind === 143 - || kind === 253 - || kind === 146 - || kind === 145 - || kind === 151 - || kind === 254 + || kind === 228 + || kind === 259 + || kind === 242 || kind === 224 - || kind === 142 - || kind === 219 - || kind === 279; + || kind === 183 + || kind === 151 + || kind === 235 + || kind === 233 + || kind === 238 + || kind === 226 + || kind === 149 + || kind === 148 + || kind === 229 + || kind === 232 + || kind === 236 + || kind === 144 + || kind === 256 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 257 + || kind === 227 + || kind === 143 + || kind === 222 + || kind === 283; } function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 + return kind === 224 + || kind === 243 || kind === 225 || kind === 226 - || kind === 231 - || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; + || kind === 227 + || kind === 228 + || kind === 229 + || kind === 234 + || kind === 233 + || kind === 240 + || kind === 239 + || kind === 232; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 - || kind === 210 - || kind === 218 - || kind === 205 - || kind === 203 - || kind === 202 - || kind === 208 - || kind === 209 - || kind === 207 - || kind === 204 - || kind === 215 - || kind === 212 - || kind === 214 - || kind === 216 - || kind === 217 - || kind === 201 - || kind === 206 + return kind === 214 || kind === 213 - || kind === 287; + || kind === 221 + || kind === 208 + || kind === 206 + || kind === 205 + || kind === 211 + || kind === 212 + || kind === 210 + || kind === 207 + || kind === 218 + || kind === 215 + || kind === 217 + || kind === 219 + || kind === 220 + || kind === 204 + || kind === 209 + || kind === 216 + || kind === 291 + || kind === 294 + || kind === 293; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -7925,87 +8188,87 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200; + || kind === 203; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 241 - || kind === 140 + return kind === 244 + || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 244; + return node.kind === 247; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245; + return node.kind === 248; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 173; + || kind === 176; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 + return kind === 245 + || kind === 251 + || kind === 246 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 - || kind === 247; + return kind === 249 + || kind === 250; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247; + return node.kind === 250; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246; + return node.kind === 249; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 248; + || kind === 251; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 - || kind === 250; + return kind === 252 + || kind === 253; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251; + return node.kind === 254; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252; + return node.kind === 255; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 253; + return node.kind === 256; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254; + return node.kind === 257; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 256; + return node.kind === 260; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8016,6 +8279,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5: case 4: return "lib.es2017.d.ts"; case 3: @@ -8143,9 +8407,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 142) { + if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 226) { return current; } } @@ -8153,11 +8417,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 || ts.isBindingPattern(node))) { + while (node && (node.kind === 173 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8165,14 +8429,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= ts.getModifierFlags(node); } return flags; @@ -8181,14 +8445,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= node.flags; } return flags; @@ -8200,7 +8464,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 260 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -8370,7 +8634,7 @@ var ts; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(141, location); + var node = createNode(142, location); node.expression = expression; return node; } @@ -8382,12 +8646,8 @@ var ts; return node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(name, initializer, location) { - return createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(143, location, flags); + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(144, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -8397,16 +8657,16 @@ var ts; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + ts.createParameter = createParameter; + function updateParameter(node, decorators, modifiers, name, type, initializer) { if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); + return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; + ts.updateParameter = updateParameter; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(146, location); + var node = createNode(147, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8424,7 +8684,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -8444,7 +8704,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -8462,7 +8722,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8481,7 +8741,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(151, location, flags); + var node = createNode(152, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8499,7 +8759,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(171, location); node.elements = createNodeArray(elements); return node; } @@ -8512,7 +8772,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -8525,7 +8785,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(173, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8541,7 +8801,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(174, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -8557,7 +8817,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(175, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -8573,7 +8833,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8590,7 +8850,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(177, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -8604,7 +8864,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(178, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -8621,7 +8881,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -8636,7 +8896,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(180, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -8650,7 +8910,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(182, location); node.expression = expression; return node; } @@ -8663,7 +8923,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(183, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -8682,7 +8942,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(181, location, flags); + var node = createNode(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -8700,7 +8960,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8713,7 +8973,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8726,7 +8986,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8739,7 +8999,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -8752,7 +9012,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(189, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -8766,7 +9026,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(190, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -8782,7 +9042,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(188, location); + var node = createNode(191, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -8797,7 +9057,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(192, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -8814,7 +9074,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(193, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -8828,7 +9088,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(194, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -8842,7 +9102,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(195, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -8855,7 +9115,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(196, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -8873,12 +9133,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(197, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(198, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -8892,7 +9152,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(201, location); node.expression = expression; node.literal = literal; return node; @@ -8906,7 +9166,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(203, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -8922,7 +9182,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(204, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -8937,7 +9197,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(223, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -8950,7 +9210,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(222, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -8965,11 +9225,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(205, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(206, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -8982,7 +9242,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(207, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -8997,7 +9257,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(208, location); node.statement = statement; node.expression = expression; return node; @@ -9011,7 +9271,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(209, location); node.expression = expression; node.statement = statement; return node; @@ -9025,7 +9285,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(210, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9041,7 +9301,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(211, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9056,7 +9316,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9071,7 +9331,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(213, location); if (label) { node.label = label; } @@ -9086,7 +9346,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -9101,7 +9361,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(215, location); node.expression = expression; return node; } @@ -9114,7 +9374,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(216, location); node.expression = expression; node.statement = statement; return node; @@ -9128,7 +9388,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(217, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9142,7 +9402,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(218, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -9156,7 +9416,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(219, location); node.expression = expression; return node; } @@ -9169,7 +9429,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(220, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9184,7 +9444,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(231, location); node.clauses = createNodeArray(clauses); return node; } @@ -9197,7 +9457,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(221, location, flags); + var node = createNode(224, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -9217,7 +9477,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(225, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -9235,7 +9495,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(234, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -9251,7 +9511,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(235, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -9265,7 +9525,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(236, location); node.name = name; return node; } @@ -9278,7 +9538,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(237, location); node.elements = createNodeArray(elements); return node; } @@ -9291,7 +9551,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(238, location); node.propertyName = propertyName; node.name = name; return node; @@ -9305,7 +9565,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(239, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -9321,7 +9581,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -9337,7 +9597,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(241, location); node.elements = createNodeArray(elements); return node; } @@ -9350,7 +9610,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(242, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -9364,7 +9624,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(245, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9379,7 +9639,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(246, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9393,7 +9653,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -9407,7 +9667,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(248, location); node.tagName = tagName; return node; } @@ -9420,7 +9680,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(249, location); node.name = name; node.initializer = initializer; return node; @@ -9434,7 +9694,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(250, location); node.expression = expression; return node; } @@ -9447,7 +9707,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -9460,7 +9720,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(254, location); node.token = token; node.types = createNodeArray(types); return node; @@ -9474,7 +9734,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(252, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -9488,7 +9748,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(253, location); node.statements = createNodeArray(statements); return node; } @@ -9501,7 +9761,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(255, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -9515,7 +9775,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(256, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -9530,12 +9790,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function createSpreadAssignment(expression, location) { + var node = createNode(258, location); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); @@ -9543,9 +9809,16 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSpreadAssignment(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpreadAssignment(expression, node), node); + } + return node; + } + ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(256, node, node.flags); + var updated = createNode(260, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -9607,13 +9880,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(291, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(293); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(292, location || original); node.expression = expression; node.original = original; return node; @@ -9685,10 +9972,6 @@ var ts; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); - } - ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { return createCall(createPropertyAccess(func, "call"), undefined, [ thisArg @@ -9724,7 +10007,20 @@ var ts; react.parent = ts.getParseTreeNode(parent); return react; } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536)); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -9744,9 +10040,21 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), undefined, argumentsList, location); + return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); } - ts.createReactCreateElement = createReactCreateElement; + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function createExportDefault(expression) { + return createExportAssignment(undefined, undefined, false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function createLetStatement(name, initializer, location) { + return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + } + ts.createLetStatement = createLetStatement; function createLetDeclarationList(declarations, location) { return createVariableDeclarationList(declarations, location, 1); } @@ -9818,13 +10126,13 @@ var ts; return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); } function createGeti(target) { - return createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createElementAccess(target, createIdentifier("name"))); + return createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createElementAccess(target, createIdentifier("name"))); } function createSeti(target) { return createArrowFunction(undefined, undefined, [ - createParameter("name"), - createParameter("value") - ], undefined, undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); + createParameter(undefined, undefined, undefined, "name"), + createParameter(undefined, undefined, undefined, "value") + ], undefined, createToken(35), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } function createAdvancedAsyncSuperHelper() { var createCache = createVariableStatement(undefined, createConstDeclarationList([ @@ -9833,20 +10141,20 @@ var ts; var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) ])); - var setter = createSetAccessor(undefined, undefined, "value", [createParameter("v")], createBlock([ + var setter = createSetAccessor(undefined, undefined, "value", [createParameter(undefined, undefined, undefined, "v")], createBlock([ createStatement(createCall(createIdentifier("seti"), undefined, [ createIdentifier("name"), createIdentifier("v") ])) ])); - var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ getter, setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ - createParameter("geti"), - createParameter("seti") + createParameter(undefined, undefined, undefined, "geti"), + createParameter(undefined, undefined, undefined, "seti") ], undefined, createBlock([ createCache, getOrCreateAccessorsForName @@ -9872,13 +10180,13 @@ var ts; case 8: case 9: return false; - case 171: + case 174: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 175: return target.properties.length > 0; default: return true; @@ -9898,7 +10206,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 176: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -9909,7 +10217,7 @@ var ts; } break; } - case 174: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -9959,14 +10267,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 150: case 151: + case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253: + case 256: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 257: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -10007,6 +10315,59 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 262144); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (getEmitFlags(node) & 262144) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 131072); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (getEmitFlags(node) & 131072) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name_11 = getMutableClone(node.name); + emitFlags |= getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(name_11, emitFlags); + return name_11; + } + return getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } @@ -10068,7 +10429,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 182) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -10077,15 +10438,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(191, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(191, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 191) { + && operand.kind === 194) { return false; } return true; @@ -10124,7 +10485,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 191 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -10141,9 +10502,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 178: return createParen(expression); - case 176: + case 179: return emittedExpression.arguments ? expression : createParen(expression); @@ -10154,7 +10515,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 179 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -10192,7 +10553,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(188, 25); + var commaPrecedence = ts.getOperatorPrecedence(191, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -10203,7 +10564,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 183 || kind === 184) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -10211,7 +10572,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 175 || leftmostExpressionKind === 183) { return createParen(expression, expression); } } @@ -10229,21 +10590,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 190: node = node.operand; continue; - case 188: + case 191: node = node.left; continue; - case 189: + case 192: node = node.condition; continue; - case 175: - case 174: - case 173: + case 178: + case 177: + case 176: node = node.expression; continue; - case 288: + case 292: node = node.expression; continue; } @@ -10252,7 +10613,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 175) { return createParen(body, body); } return body; @@ -10277,7 +10638,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 182) { node = node.expression; } return node; @@ -10291,7 +10652,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 292) { node = node.expression; } return node; @@ -10347,7 +10708,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 260) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10437,13 +10798,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_12 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 231 && node.importClause) { + if (node.kind === 234 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 240 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -10481,6 +10842,221 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } + function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + context.startLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = addPrologueDirectives(statements, body.statements, false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); + addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 184); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = createReturn(expression, body); + setEmitFlags(returnStatement, 12288 | 1024 | 32768); + statements.push(returnStatement); + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + setEmitFlags(block, 32); + } + if (closeBraceLocation) { + setTokenSourceMapRange(block, 17, closeBraceLocation); + } + setOriginalNode(block, node.body); + return block; + } + ts.transformFunctionBody = transformFunctionBody; + function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { + if (node.transformFlags & 524288 && node.kind !== 184) { + captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + } + } + ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; + function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + setEmitFlags(captureThisStatement, 49152 | 8388608); + setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + ts.captureThisForNode = captureThisForNode; + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 2097152) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_13 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_13)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_13, initializer, visitor, convertObjectRest); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_13, initializer, visitor); + } + } + } + ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { + var temp = getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608)); + } + else if (initializer) { + statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + } + } + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ + createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536), setEmitFlags(initializer, 1536 | getEmitFlags(initializer)), parameter)) + ], parameter), 32 | 1024 | 12288), undefined, parameter); + statement.startsOnNewLine = true; + setEmitFlags(statement, 12288 | 1024 | 8388608); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + var declarationName = getMutableClone(parameter.name); + setEmitFlags(declarationName, 1536); + var expressionName = getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = createLoopVariable(); + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration(declarationName, undefined, createArrayLiteral([])) + ]), parameter), 8388608)); + var forStatement = createFor(createVariableDeclarationList([ + createVariableDeclaration(temp, undefined, createLiteral(restIndex)) + ], parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), parameter), createPostfixIncrement(temp, parameter), createBlock([ + startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), parameter)) + ])); + setEmitFlags(forStatement, 8388608); + startOnNewLine(forStatement); + statements.push(forStatement); + } + ts.addRestParameterIfNeeded = addRestParameterIfNeeded; + function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = convertObjectRest ? undefined : createLoopVariable(); + var rhsReference = expression.kind === 70 + ? createUniqueName(expression.text) + : createTempVariable(undefined); + var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, undefined, convertObjectRest); + var declarationList = createVariableDeclarationList(declarations, initializer); + setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(createVariableStatement(undefined, declarationList)); + } + else { + statements.push(createVariableStatement(undefined, setOriginalNode(createVariableDeclarationList([ + createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(undefined), undefined, createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + } + } + else { + var assignment = createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, false, context.hoistVariableDeclaration, visitor, convertObjectRest))); + } + else { + assignment.end = initializer.end; + statements.push(createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + setEmitFlags(expression, 1536 | getEmitFlags(expression)); + var body = createBlock(createNodeArray(statements, statementsLocation), bodyLocation); + setEmitFlags(body, 1536 | 12288); + var forStatement; + if (convertObjectRest) { + forStatement = createForOf(createVariableDeclarationList([ + createVariableDeclaration(rhsReference, undefined, undefined, node.expression) + ], node.expression), node.expression, body, node); + } + else { + forStatement = createFor(setEmitFlags(createVariableDeclarationList([ + createVariableDeclaration(counter, undefined, createLiteral(0), ts.moveRangePos(node.expression, -1)), + createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), 16777216), createLessThan(counter, createPropertyAccess(rhsReference, "length"), node.expression), createPostfixIncrement(counter, node.expression), body, node); + } + setEmitFlags(forStatement, 8192); + return forStatement; + } + ts.convertForOf = convertForOf; })(ts || (ts = {})); var ts; (function (ts) { @@ -10489,13 +11065,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 260) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 140) { + else if (kind < 141) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -10531,26 +11107,28 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 140: + case 141: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 142: + case 143: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 254: + case 257: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 143: + case 258: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 256: + case 222: + case 173: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -10559,24 +11137,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 157: case 158: - case 152: + case 159: case 153: case 154: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 180: - case 221: - case 181: + case 152: + case 183: + case 224: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -10587,309 +11165,313 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 156: + case 157: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 155: + case 156: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 159: - return visitNode(cbNode, node.exprName); case 160: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 161: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 162: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 163: + return visitNodes(cbNodes, node.elementTypes); case 164: - return visitNodes(cbNodes, node.types); case 165: - return visitNode(cbNode, node.type); - case 167: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 166: case 168: + return visitNode(cbNode, node.type); case 169: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.objectType) || + visitNode(cbNode, node.indexType); + case 170: + return visitNode(cbNode, node.literal); case 171: - return visitNodes(cbNodes, node.elements); case 172: + return visitNodes(cbNodes, node.elements); + case 174: + return visitNodes(cbNodes, node.elements); + case 175: return visitNodes(cbNodes, node.properties); - case 173: + case 176: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 178: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 180: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 181: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179: - return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 186: - return visitNode(cbNode, node.operand); - case 191: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 185: return visitNode(cbNode, node.expression); + case 186: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.expression); + case 189: return visitNode(cbNode, node.operand); + case 194: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 191: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 199: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 200: return visitNode(cbNode, node.expression); - case 189: + case 192: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 195: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 203: + case 230: return visitNodes(cbNodes, node.statements); - case 256: + case 260: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 204: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 223: return visitNodes(cbNodes, node.declarations); - case 203: + case 206: return visitNode(cbNode, node.expression); - case 204: + case 207: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 208: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 210: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 209: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 210: case 211: - return visitNode(cbNode, node.label); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: + case 214: + return visitNode(cbNode, node.label); + case 215: + return visitNode(cbNode, node.expression); + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214: + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228: + case 231: return visitNodes(cbNodes, node.clauses); - case 249: + case 252: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250: + case 253: return visitNodes(cbNodes, node.statements); - case 215: + case 218: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216: + case 219: return visitNode(cbNode, node.expression); - case 217: + case 220: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 255: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 223: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 224: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); case 225: + case 196: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 255: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 226: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 227: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 228: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 259: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230: + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 235: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: + case 232: return visitNode(cbNode, node.name); - case 233: + case 236: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + case 241: + return visitNodes(cbNodes, node.elements); + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: - case 239: + case 238: + case 242: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 239: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 193: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 254: return visitNodes(cbNodes, node.types); - case 195: + case 198: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 244: return visitNode(cbNode, node.expression); - case 240: + case 243: return visitNodes(cbNodes, node.decorators); - case 242: + case 245: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 246: + case 247: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 249: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 250: + return visitNode(cbNode, node.expression); + case 251: return visitNode(cbNode, node.expression); case 248: - return visitNode(cbNode, node.expression); - case 245: return visitNode(cbNode, node.tagName); - case 257: - return visitNode(cbNode, node.type); case 261: - return visitNodes(cbNodes, node.types); - case 262: - return visitNodes(cbNodes, node.types); - case 260: - return visitNode(cbNode, node.elementType); - case 264: - return visitNode(cbNode, node.type); - case 263: return visitNode(cbNode, node.type); case 265: - return visitNode(cbNode, node.literal); - case 267: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 266: + return visitNodes(cbNodes, node.types); + case 264: + return visitNode(cbNode, node.elementType); case 268: return visitNode(cbNode, node.type); + case 267: + return visitNode(cbNode, node.type); case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 271: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 272: return visitNode(cbNode, node.type); - case 266: + case 273: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 270: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 277: return visitNodes(cbNodes, node.tags); - case 275: + case 279: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 280: return visitNode(cbNode, node.typeExpression); - case 277: + case 281: return visitNode(cbNode, node.typeExpression); - case 278: + case 282: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 283: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 285: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 284: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 292: return visitNode(cbNode, node.expression); - case 282: + case 286: return visitNode(cbNode, node.literal); } } @@ -10903,6 +11485,10 @@ var ts; return result; } ts.createSourceFile = createSourceFile; + function parseIsolatedEntityName(text, languageVersion) { + return Parser.parseIsolatedEntityName(text, languageVersion); + } + ts.parseIsolatedEntityName = parseIsolatedEntityName; function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -10925,8 +11511,8 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(4, true); - var disallowInAndDecoratorContext = 32768 | 131072; + var scanner = ts.createScanner(5, true); + var disallowInAndDecoratorContext = 65536 | 262144; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -10950,6 +11536,15 @@ var ts; return result; } Parser.parseSourceFile = parseSourceFile; + function parseIsolatedEntityName(content, languageVersion) { + initializeState(content, languageVersion, undefined, 1); + nextToken(); + var entityName = parseEntityName(true); + var isInvalid = token() === 1 && !parseDiagnostics.length; + clearState(); + return isInvalid ? entityName : undefined; + } + Parser.parseIsolatedEntityName = parseIsolatedEntityName; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } @@ -10965,7 +11560,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 1048576 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -11040,7 +11635,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(260, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -11060,17 +11655,17 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 32768); - } - function setYieldContext(val) { setContextFlag(val, 65536); } - function setDecoratorContext(val) { + function setYieldContext(val) { setContextFlag(val, 131072); } - function setAwaitContext(val) { + function setDecoratorContext(val) { setContextFlag(val, 262144); } + function setAwaitContext(val) { + setContextFlag(val, 524288); + } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; if (contextFlagsToClear) { @@ -11092,41 +11687,41 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(32768, func); + return doOutsideOfContext(65536, func); } function disallowInAnd(func) { - return doInsideOfContext(32768, func); - } - function doInYieldContext(func) { return doInsideOfContext(65536, func); } - function doInDecoratorContext(func) { + function doInYieldContext(func) { return doInsideOfContext(131072, func); } - function doInAwaitContext(func) { + function doInDecoratorContext(func) { return doInsideOfContext(262144, func); } + function doInAwaitContext(func) { + return doInsideOfContext(524288, func); + } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144, func); + return doOutsideOfContext(524288, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 | 262144, func); + return doInsideOfContext(131072 | 524288, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(65536); - } - function inDisallowInContext() { - return inContext(32768); - } - function inDecoratorContext() { return inContext(131072); } - function inAwaitContext() { + function inDisallowInContext() { + return inContext(65536); + } + function inDecoratorContext() { return inContext(262144); } + function inAwaitContext() { + return inContext(524288); + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; @@ -11267,7 +11862,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + return kind >= 141 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -11287,7 +11882,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -11349,7 +11944,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(141); + var node = createNode(142); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -11419,9 +12014,11 @@ var ts; case 6: return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + case 17: + return isLiteralPropertyName(); case 9: - return token() === 20 || isLiteralPropertyName(); + return token() === 20 || token() === 23 || isLiteralPropertyName(); case 7: if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); @@ -11436,29 +12033,29 @@ var ts; return isIdentifierOrPattern(); case 10: return token() === 25 || token() === 23 || isIdentifierOrPattern(); - case 17: + case 18: return isIdentifier(); case 11: case 15: return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); - case 18: case 19: - return token() === 25 || isStartOfType(); case 20: - return isHeritageClause(); + return token() === 25 || isStartOfType(); case 21: + return isHeritageClause(); + case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; - case 22: case 23: - case 25: - return JSDocParser.isJSDocType(); case 24: + case 26: + return JSDocParser.isJSDocType(); + case 25: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -11502,7 +12099,7 @@ var ts; case 6: case 12: case 9: - case 21: + case 22: return token() === 17; case 3: return token() === 17 || token() === 72 || token() === 78; @@ -11510,31 +12107,32 @@ var ts; return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); - case 17: + case 18: return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: return token() === 19 || token() === 24; case 15: - case 19: + case 20: case 10: return token() === 21; case 16: + case 17: return token() === 19 || token() === 21; - case 18: + case 19: return token() !== 25; - case 20: + case 21: return token() === 16 || token() === 17; case 13: return token() === 28 || token() === 40; case 14: return token() === 26 && lookAhead(nextTokenIsSlash); - case 22: - return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 28 || token() === 17; - case 25: - return token() === 21 || token() === 17; + return token() === 19 || token() === 55 || token() === 17; case 24: + return token() === 28 || token() === 17; + case 26: + return token() === 21 || token() === 17; + case 25: return token() === 17; } } @@ -11551,7 +12149,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 26; kind++) { + for (var kind = 0; kind < 27; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -11602,7 +12200,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -11634,10 +12232,12 @@ var ts; return isReusableVariableDeclaration(node); case 16: return isReusableParameter(node); - case 20: case 17: - case 19: + return false; + case 21: case 18: + case 20: + case 19: case 11: case 12: case 7: @@ -11649,14 +12249,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 149: - case 154: case 150: + case 155: case 151: - case 146: - case 199: + case 152: + case 147: + case 202: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -11668,8 +12268,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 252: + case 253: return true; } } @@ -11678,65 +12278,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 224: case 204: case 203: - case 216: - case 212: - case 214: - case 211: - case 210: - case 208: - case 209: case 207: case 206: - case 213: - case 202: - case 217: + case 219: case 215: + case 217: + case 214: + case 213: + case 211: + case 212: + case 210: + case 209: + case 216: case 205: + case 220: case 218: - case 231: - case 230: - case 237: - case 236: - case 226: - case 222: - case 223: + case 208: + case 221: + case 234: + case 233: + case 240: + case 239: + case 229: case 225: - case 224: + case 226: + case 228: + case 227: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 153: - case 147: case 154: - case 145: - case 152: + case 148: + case 155: + case 146: + case 153: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 219) { + if (node.kind !== 222) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var parameter = node; @@ -11756,6 +12356,7 @@ var ts; case 1: return ts.Diagnostics.Declaration_or_statement_expected; case 2: return ts.Diagnostics.case_or_default_expected; case 3: return ts.Diagnostics.Statement_expected; + case 17: case 4: return ts.Diagnostics.Property_or_signature_expected; case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; case 6: return ts.Diagnostics.Enum_member_expected; @@ -11767,17 +12368,17 @@ var ts; case 12: return ts.Diagnostics.Property_assignment_expected; case 15: return ts.Diagnostics.Expression_or_comma_expected; case 16: return ts.Diagnostics.Parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18: return ts.Diagnostics.Type_argument_expected; - case 19: return ts.Diagnostics.Type_expected; - case 20: return ts.Diagnostics.Unexpected_token_expected; - case 21: return ts.Diagnostics.Identifier_expected; + case 18: return ts.Diagnostics.Type_parameter_declaration_expected; + case 19: return ts.Diagnostics.Type_argument_expected; + case 20: return ts.Diagnostics.Type_expected; + case 21: return ts.Diagnostics.Unexpected_token_expected; + case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; - case 22: return ts.Diagnostics.Parameter_declaration_expected; - case 23: return ts.Diagnostics.Type_argument_expected; - case 25: return ts.Diagnostics.Type_expected; - case 24: return ts.Diagnostics.Property_assignment_expected; + case 23: return ts.Diagnostics.Parameter_declaration_expected; + case 24: return ts.Diagnostics.Type_argument_expected; + case 26: return ts.Diagnostics.Type_expected; + case 25: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -11831,7 +12432,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(140, entity.pos); + var node = createNode(141, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -11848,7 +12449,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(193); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -11860,7 +12461,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(201); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -11908,33 +12509,33 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(156, typeName.pos); + var node = createNode(157, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(155, lhs.pos); + var node = createNode(156, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(166); + var node = createNode(167); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(159); + var node = createNode(160); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(142); + var node = createNode(143); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -11948,7 +12549,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -11961,7 +12562,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(143); + var node = createNode(144); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -12021,7 +12622,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -12061,7 +12662,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(154, fullStart); + var node = createNode(155, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -12073,7 +12674,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -12082,7 +12683,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -12122,10 +12723,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(152); + return parseSignatureMember(153); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(153); + return parseSignatureMember(154); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -12139,7 +12740,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -12155,12 +12756,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(162); - node.elementTypes = parseBracketedList(19, parseType, 20, 21); + var node = createNode(163); + node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(165); + var node = createNode(166); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -12168,7 +12769,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -12179,7 +12780,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(170); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -12190,12 +12791,12 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: - case 136: - case 128: + case 132: + case 121: + case 135: + case 137: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -12232,16 +12833,16 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: case 98: case 102: - case 128: + case 129: case 16: case 20: case 26: @@ -12266,13 +12867,36 @@ var ts; function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { - parseExpected(21); - var node = createNode(161, type.pos); - node.elementType = type; - type = finishNode(node); + if (isStartOfType()) { + var node = createNode(169, type.pos); + node.objectType = type; + node.indexType = parseType(); + parseExpected(21); + type = finishNode(node); + } + else { + var node = createNode(162, type.pos); + node.elementType = type; + parseExpected(21); + type = finishNode(node); + } } return type; } + function parseTypeOperator(operator) { + var node = createNode(168); + parseExpected(operator); + node.operator = operator; + node.type = parseTypeOperatorOrHigher(); + return finishNode(node); + } + function parseTypeOperatorOrHigher() { + switch (token()) { + case 126: + return parseTypeOperator(126); + } + return parseArrayTypeOrHigher(); + } function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { var type = parseConstituentType(); if (token() === operator) { @@ -12288,10 +12912,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); + return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -12337,7 +12961,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(155, typePredicateVariable.pos); + var node = createNode(156, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -12354,14 +12978,14 @@ var ts; } } function parseType() { - return doOutsideOfContext(327680, parseTypeWorker); + return doOutsideOfContext(655360, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(157); + return parseFunctionOrConstructorType(158); } if (token() === 93) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } return parseUnionTypeOrHigher(); } @@ -12480,7 +13104,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(194); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -12496,13 +13120,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(181, asyncModifier.pos); + node = createNode(184, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(184, identifier.pos); } - var parameter = createNode(143, identifier.pos); + var parameter = createNode(144, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -12636,7 +13260,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(184); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -12668,7 +13292,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(192, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -12681,7 +13305,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 139; + return t === 91 || t === 140; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -12759,39 +13383,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(191, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(196, left.pos); + var node = createNode(199, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -12806,7 +13430,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -12822,7 +13446,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 181) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, 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 { @@ -12875,7 +13499,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -12887,7 +13511,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(187, expression.pos); + var node = createNode(190, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -12910,7 +13534,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(176, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -12932,8 +13556,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 244) { - var node = createNode(242, opening.pos); + if (opening.kind === 247) { + var node = createNode(245, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -12943,14 +13567,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 246); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(188, result.pos); + var badNode = createNode(191, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -13003,7 +13627,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(247, fullStart); scanJsxText(); } else { @@ -13015,7 +13639,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(246, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -13026,7 +13650,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13034,7 +13658,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(251); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -13053,7 +13677,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(249); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -13068,7 +13692,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(250); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -13076,7 +13700,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(248); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -13089,7 +13713,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(181); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -13100,7 +13724,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -13108,13 +13732,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(200, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(177, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -13128,7 +13752,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(180, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -13147,7 +13771,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -13155,7 +13779,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -13174,7 +13798,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -13250,28 +13874,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(182); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(195); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(197) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(174); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -13282,15 +13906,21 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(150, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(132)) { return parseAccessorDeclaration(151, fullStart, decorators, modifiers); } + else if (parseContextualModifier(133)) { + return parseAccessorDeclaration(152, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var dotDotDotToken = parseOptionalToken(23); + if (dotDotDotToken) { + var spreadElement = createNode(258, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -13306,7 +13936,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(257, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -13317,7 +13947,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(256, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -13327,7 +13957,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(175); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -13341,7 +13971,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(183); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -13363,7 +13993,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(179); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -13373,7 +14003,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(203); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -13404,12 +14034,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(205); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(207); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -13419,7 +14049,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(208); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -13430,7 +14060,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(209); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -13453,21 +14083,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(211, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(139)) { - var forOfStatement = createNode(209, pos); + else if (parseOptional(140)) { + var forOfStatement = createNode(212, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(210, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -13485,7 +14115,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 214 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -13493,7 +14123,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(215); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -13502,7 +14132,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(216); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -13511,7 +14141,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(252); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -13519,7 +14149,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(253); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -13529,12 +14159,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(217); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(231, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -13542,14 +14172,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(219); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(220); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -13560,7 +14190,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(255); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -13570,7 +14200,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(221); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -13579,13 +14209,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(215, fullStart); + var labeledStatement = createNode(218, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(206, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -13614,10 +14244,10 @@ var ts; case 82: return true; case 108: - case 135: + case 136: return nextTokenIsIdentifierOnSameLine(); - case 126: case 127: + case 128: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 116: case 119: @@ -13625,13 +14255,13 @@ var ts; case 111: case 112: case 113: - case 129: + case 130: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 138: + case 139: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -13689,16 +14319,16 @@ var ts; case 119: case 123: case 108: - case 126: case 127: - case 135: - case 138: + case 128: + case 136: + case 139: return true; case 113: case 111: case 112: case 114: - case 129: + case 130: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -13737,9 +14367,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(213); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(214); case 95: return parseReturnStatement(); case 106: @@ -13758,9 +14388,9 @@ var ts; return parseDeclaration(); case 119: case 108: - case 135: - case 126: + case 136: case 127: + case 128: case 123: case 75: case 82: @@ -13771,8 +14401,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -13795,13 +14425,13 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 135: + case 136: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 138: - case 126: + case 139: case 127: + case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -13818,7 +14448,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(243, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -13839,16 +14469,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(197); } - var node = createNode(170); + var node = createNode(173); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(173); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -13863,14 +14494,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(171); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(172); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -13889,7 +14520,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(222); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -13898,7 +14529,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(223); switch (token()) { case 103: break; @@ -13912,7 +14543,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -13927,7 +14558,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(204, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -13935,7 +14566,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -13948,7 +14579,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(149, pos); + var node = createNode(150, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -13957,7 +14588,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -13970,7 +14601,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -13978,7 +14609,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(65536 | 32768, parseNonParameterInitializer); + : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -14011,7 +14642,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -14040,7 +14671,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { return true; } switch (token()) { @@ -14063,7 +14694,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(144, decoratorStart); + var decorator = createNode(145, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -14120,7 +14751,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(202); nextToken(); return finishNode(result); } @@ -14145,16 +14776,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_10 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, undefined); + var name_14 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 196); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 225); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -14183,13 +14814,13 @@ var ts; } function parseHeritageClauses() { if (isHeritageClause()) { - return parseList(20, parseHeritageClause); + return parseList(21, parseHeritageClause); } return undefined; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(251); + var node = createNode(254); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -14198,10 +14829,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(198); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -14212,7 +14843,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -14223,10 +14854,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -14235,13 +14866,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(259, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -14256,7 +14887,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(230, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -14267,7 +14898,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -14279,10 +14910,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -14299,14 +14930,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 138) { + if (token() === 139) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(127)) { + else if (parseOptional(128)) { flags |= 16; } else { - parseExpected(126); + parseExpected(127); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -14314,7 +14945,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -14324,11 +14955,11 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(232, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); @@ -14339,8 +14970,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 137) { - var importEqualsDeclaration = createNode(230, fullStart); + if (token() !== 25 && token() !== 138) { + var importEqualsDeclaration = createNode(233, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -14350,27 +14981,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(234, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137); + parseExpected(138); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(232, fullStart); + var importClause = createNode(235, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(237); } return finishNode(importClause); } @@ -14380,8 +15011,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(244); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -14398,7 +15029,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(236); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -14406,14 +15037,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 237 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(242); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(238); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -14432,23 +15063,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 238 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(237, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(137); + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(238); - if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(137); + node.exportClause = parseNamedImportsOrExports(241); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -14456,7 +15087,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(239, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -14535,10 +15166,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 230 && node.moduleReference.kind === 241 - || node.kind === 231 - || node.kind === 236 - || node.kind === 237 + || node.kind === 233 && node.moduleReference.kind === 244 + || node.kind === 234 + || node.kind === 239 + || node.kind === 240 ? node : undefined; }); @@ -14563,8 +15194,8 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState(content, 4, undefined, 1); - sourceFile = createSourceFile("file.js", 4, 1); + initializeState(content, 5, undefined, 1); + sourceFile = createSourceFile("file.js", 5, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -14574,7 +15205,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(261, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -14585,12 +15216,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(265, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(272, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -14601,20 +15232,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(264, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(267, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(268, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -14648,14 +15279,14 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: case 94: - case 136: - case 128: + case 137: + case 129: return parseTokenNode(); case 9: case 8: @@ -14666,30 +15297,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(275); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(273); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -14699,7 +15330,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(143); + var parameter = createNode(144); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -14707,7 +15338,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(271); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -14727,7 +15358,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -14741,26 +15372,26 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(140, left.pos); + var result = createNode(141, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(265); + var result = createNode(269); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(268); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(266); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -14772,7 +15403,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(265); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -14788,12 +15419,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(262); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(286); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -14806,17 +15437,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(263, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(267, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState(content, 4, undefined, 1); + initializeState(content, 5, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -14949,7 +15580,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(277, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -15056,7 +15687,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(278, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -15111,7 +15742,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -15122,20 +15753,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 276; })) { + if (ts.forEach(tags, function (t) { return t.kind === 280; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 277; })) { + if (ts.forEach(tags, function (t) { return t.kind === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -15150,7 +15781,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -15160,7 +15791,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(283, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -15174,11 +15805,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 271) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_11 = jsDocTypeReference.name; - if (name_11.text === "Object") { + var name_15 = jsDocTypeReference.name; + if (name_15.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -15192,7 +15823,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(285, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -15233,7 +15864,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(226, pos); + var jsDocNamespaceNode = createNode(229, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -15277,19 +15908,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 278; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_12 = parseJSDocIdentifierName(); + var name_16 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_12) { + if (!name_16) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(142, name_12.pos); - typeParameter.name = name_12; + var typeParameter = createNode(143, name_16.pos); + typeParameter.name = name_16; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -15300,7 +15931,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -15619,16 +16250,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 226 || node.kind === 227) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 234 || node.kind === 233) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 230) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -15644,7 +16275,7 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 229) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -15753,7 +16384,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 229)) { symbol.valueDeclaration = node; } } @@ -15763,7 +16394,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 141) { + if (node.name.kind === 142) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -15774,21 +16405,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 149: + case 150: return "__constructor"; - case 157: - case 152: - return "__call"; case 158: case 153: - return "__new"; + return "__call"; + case 159: case 154: + return "__new"; + case 155: return "__index"; - case 237: + case 240: return "__export"; - case 236: + case 239: return node.isExportEquals ? "export=" : "default"; - case 188: + case 191: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -15800,20 +16431,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 224: + case 225: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 273: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 273); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 283: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 204) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -15857,7 +16488,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 239 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -15877,7 +16508,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { + if (node.kind === 242 || (node.kind === 233 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -15885,7 +16516,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 279 && + var isJSDocTypedefInJSDocNamespace = node.kind === 283 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -15924,7 +16555,7 @@ var ts; var saveReturnTarget = currentReturnTarget; var saveActiveLabels = activeLabels; var saveHasExplicitReturn = hasExplicitReturn; - var isIIFE = containerFlags & 16 && !!ts.getImmediatelyInvokedFunctionExpression(node); + var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) && !!ts.getImmediatelyInvokedFunctionExpression(node); if (isIIFE) { currentReturnTarget = createBranchLabel(); } @@ -15940,13 +16571,13 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~32128; + node.flags &= ~64896; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 256) { + if (node.kind === 260) { node.flags |= emitFlags; } if (isIIFE) { @@ -15999,64 +16630,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 209: bindWhileStatement(node); break; - case 205: + case 208: bindDoStatement(node); break; - case 207: + case 210: bindForStatement(node); break; - case 208: - case 209: + case 211: + case 212: bindForInOrForOfStatement(node); break; - case 204: + case 207: bindIfStatement(node); break; - case 212: - case 216: + case 215: + case 219: bindReturnOrThrow(node); break; - case 211: - case 210: + case 214: + case 213: bindBreakOrContinueStatement(node); break; - case 217: + case 220: bindTryStatement(node); break; - case 214: + case 217: bindSwitchStatement(node); break; - case 228: + case 231: bindCaseBlock(node); break; - case 249: + case 252: bindCaseClause(node); break; - case 215: + case 218: bindLabeledStatement(node); break; - case 186: + case 189: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 190: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 191: bindBinaryExpressionFlow(node); break; - case 182: + case 185: bindDeleteExpressionFlow(node); break; - case 189: + case 192: bindConditionalExpressionFlow(node); break; - case 219: + case 222: bindVariableDeclarationFlow(node); break; - case 175: + case 178: bindCallExpressionFlow(node); break; default: @@ -16068,15 +16699,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return isNarrowableReference(expr); - case 175: + case 178: return hasNarrowableArgument(expr); - case 179: + case 182: return isNarrowingExpression(expr.expression); - case 188: + case 191: return isNarrowingBinaryExpression(expr); - case 186: + case 189: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -16084,7 +16715,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 176 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -16095,14 +16726,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 176 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 186 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -16123,9 +16754,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 182: return isNarrowableOperand(expr.expression); - case 188: + case 191: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -16219,33 +16850,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: - return parent.expression === node; case 207: - case 189: + case 209: + case 208: + return parent.expression === node; + case 210: + case 192: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 182) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 189 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 191 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 182 || + node.parent.kind === 189 && node.parent.operator === 50) { node = node.parent; } @@ -16287,8 +16918,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 218 + ? ts.lastOrUndefined(activeLabels) + : undefined; + var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); + var postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel(); addAntecedent(preDoLabel, currentFlow); currentFlow = preDoLabel; bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); @@ -16319,7 +16953,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 223) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -16341,7 +16975,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 215) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -16361,7 +16995,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 214 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -16418,7 +17052,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 250; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 253; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -16479,11 +17113,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); + if (!node.statement || node.statement.kind !== 208) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 191 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -16494,10 +17130,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 174) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 195) { bindAssignmentTargetFlow(e.expression); } else { @@ -16505,15 +17141,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 175) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 256) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 257) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 258) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -16565,9 +17204,9 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 57 && !ts.isAssignmentTarget(node)) { + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (node.left.kind === 174) { + if (operator === 57 && node.left.kind === 177) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -16578,7 +17217,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { bindAssignmentTargetFlow(node.expression); } } @@ -16588,9 +17227,11 @@ var ts; var postExpressionLabel = createBranchLabel(); bindCondition(node.condition, trueLabel, falseLabel); currentFlow = finishFlowLabel(trueLabel); + bind(node.questionToken); bind(node.whenTrue); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(falseLabel); + bind(node.colonToken); bind(node.whenFalse); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(postExpressionLabel); @@ -16609,16 +17250,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { + if (node.initializer || node.parent.parent.kind === 211 || node.parent.parent.kind === 212) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 182) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 183 || expr.kind === 184) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -16626,7 +17267,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -16635,51 +17276,51 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: + case 196: case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; + case 228: + case 175: + case 161: + case 285: case 269: + return 1; case 226: - case 224: + return 1 | 64; + case 273: + case 229: + case 227: return 1 | 32; - case 256: + case 260: return 1 | 4 | 32; - case 148: + case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 149: - case 221: - case 147: case 150: + case 224: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return 1 | 4 | 32 | 8; - case 180: - case 181: + case 183: + case 184: return 1 | 4 | 32 | 8 | 16; - case 227: + case 230: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 255: + case 210: + case 211: + case 212: + case 231: return 2; - case 200: + case 203: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -16695,36 +17336,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 229: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 260: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 196: case 225: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 228: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 175: + case 226: + case 269: + case 285: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 157: case 158: - case 152: + case 159: case 153: case 154: - case 148: - case 147: + case 155: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 269: + case 152: case 224: + case 183: + case 184: + case 273: + case 227: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -16739,11 +17380,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 227)) { + var body = node.kind === 260 ? node : node.body; + if (body && (body.kind === 260 || body.kind === 230)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 237 || stat.kind === 236) { + if (stat.kind === 240 || stat.kind === 239) { return true; } } @@ -16819,11 +17460,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 70) { + if (prop.kind === 258 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 256 || prop.kind === 257 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -16845,10 +17486,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 229: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 260: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -16938,8 +17579,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 260 && + blockScopeContainer.kind !== 229 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -16982,7 +17623,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 139) { + if (node.kind > 140) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -17022,23 +17663,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 279) { + while (parentNode && parentNode.kind !== 283) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 257)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 176: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 191: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -17061,115 +17702,131 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 255: return checkStrictModeCatchClause(node); - case 182: + case 185: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 190: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 189: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 216: return checkStrictModeWithStatement(node); - case 166: + case 167: seenThisKeyword = true; return; - case 155: + case 156: return checkTypePredicate(node); - case 142: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 143: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 144: return bindParameter(node); - case 219: - case 170: + case 222: + case 173: + if (node.dotDotDotToken && node.parent.kind === 171) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 270: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 284: return bindJSDocProperty(node); - case 253: - case 254: + case 256: + case 257: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 259: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 258: + case 250: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 175 && + root.parent.kind === 191 && + root.parent.operatorToken.kind === 57 && + root.parent.left === root) { + hasRest = true; + break; + } + root = root.parent; + } + emitFlags |= hasRest ? 32768 : 16384; return; - case 152: case 153: case 154: + case 155: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 148: - case 147: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 221: - return bindFunctionDeclaration(node); case 149: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 148: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 224: + return bindFunctionDeclaration(node); case 150: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 151: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 152: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 157: case 158: - case 269: + case 159: + case 273: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 285: + case 269: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: - return bindObjectLiteralExpression(node); - case 180: - case 181: - return bindFunctionExpression(node); case 175: + return bindObjectLiteralExpression(node); + case 183: + case 184: + return bindFunctionExpression(node); + case 178: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 196: + case 225: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 226: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: + case 283: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 224: + case 227: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: + case 228: return bindEnumDeclaration(node); - case 226: - return bindModuleDeclaration(node); - case 230: - case 233: - case 235: - case 239: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 229: - return bindNamespaceExportDeclaration(node); - case 232: - return bindImportClause(node); - case 237: - return bindExportDeclaration(node); + return bindModuleDeclaration(node); + case 233: case 236: + case 238: + case 242: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 232: + return bindNamespaceExportDeclaration(node); + case 235: + return bindImportClause(node); + case 240: + return bindExportDeclaration(node); + case 239: return bindExportAssignment(node); - case 256: + case 260: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 203: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 230: return updateStrictModeStatementList(node.statements); } } @@ -17178,7 +17835,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -17197,7 +17854,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 239 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -17207,17 +17864,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 256) { + if (node.parent.kind !== 260) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_6 = node.parent; - if (!ts.isExternalModule(parent_6)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_6.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -17256,11 +17913,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 224 || container.kind === 183) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 149) { + else if (container.kind === 150) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -17300,7 +17957,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 225) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -17418,15 +18075,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || - node.kind === 222 || - (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 205) || + node.kind === 225 || + (node.kind === 229 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 228 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 204 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -17440,56 +18097,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: + case 178: return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: + return computeNewExpression(node, subtreeFlags); + case 229: + return computeModuleDeclaration(node, subtreeFlags); + case 182: return computeParenthesizedExpression(node, subtreeFlags); - case 188: + case 191: return computeBinaryExpression(node, subtreeFlags); - case 203: + case 206: return computeExpressionStatement(node, subtreeFlags); - case 143: + case 144: return computeParameter(node, subtreeFlags); - case 181: + case 184: return computeArrowFunction(node, subtreeFlags); - case 180: + case 183: return computeFunctionExpression(node, subtreeFlags); - case 221: + case 224: return computeFunctionDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclaration(node, subtreeFlags); - case 220: - return computeVariableDeclarationList(node, subtreeFlags); - case 201: - return computeVariableStatement(node, subtreeFlags); - case 215: - return computeLabeledStatement(node, subtreeFlags); case 222: + return computeVariableDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclarationList(node, subtreeFlags); + case 204: + return computeVariableStatement(node, subtreeFlags); + case 218: + return computeLabeledStatement(node, subtreeFlags); + case 225: return computeClassDeclaration(node, subtreeFlags); - case 193: + case 196: return computeClassExpression(node, subtreeFlags); - case 251: + case 254: return computeHeritageClause(node, subtreeFlags); - case 252: + case 255: return computeCatchClause(node, subtreeFlags); - case 195: + case 198: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); case 150: + return computeConstructor(node, subtreeFlags); + case 147: + return computePropertyDeclaration(node, subtreeFlags); + case 149: + return computeMethod(node, subtreeFlags); case 151: + case 152: return computeAccessor(node, subtreeFlags); - case 230: + case 233: return computeImportEquals(node, subtreeFlags); - case 173: + case 176: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -17503,19 +18160,19 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576 + if (subtreeFlags & 8388608 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function isSuperOrSuperProperty(node, kind) { switch (kind) { case 96: return true; - case 173: - case 174: + case 176: + case 177: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -17527,27 +18184,28 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576) { - transformFlags |= 768; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 - && (leftKind === 172 - || leftKind === 171)) { - transformFlags |= 768 | 1024; + if (operatorTokenKind === 57 && leftKind === 175) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 174) { + transformFlags |= 3072 | 49152; } else if (operatorTokenKind === 39 || operatorTokenKind === 61) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17557,33 +18215,36 @@ var ts; var dotDotDotToken = node.dotDotDotToken; if (node.questionToken || node.type - || subtreeFlags & 8192 + || subtreeFlags & 65536 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 524288; + transformFlags |= 3 | 4194304; } - if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { - transformFlags |= 768 | 262144; + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + if (subtreeFlags & 67108864 || initializer || dotDotDotToken) { + transformFlags |= 3072 | 2097152; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 196 - || expressionKind === 178) { + if (expressionKind === 199 + || expressionKind === 181) { transformFlags |= 3; } - if (expressionTransformFlags & 1024) { - transformFlags |= 1024; + if (expressionTransformFlags & 16384) { + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -17592,36 +18253,35 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 768; - if ((subtreeFlags & 548864) - || (modifierFlags & 1) + transformFlags = subtreeFlags | 3072; + if ((subtreeFlags & 4390912) || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; - if (subtreeFlags & 548864 + var transformFlags = subtreeFlags | 3072; + if (subtreeFlags & 4390912 || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84: - transformFlags |= 768; + transformFlags |= 3072; break; case 107: transformFlags |= 3; @@ -17631,23 +18291,23 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17656,10 +18316,10 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.decorators || ts.hasModifier(node, 2270) || node.typeParameters @@ -17668,13 +18328,13 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 48; + transformFlags |= 192; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17685,15 +18345,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 16384; + transformFlags |= 131072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -17703,27 +18363,27 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 33554432; - if (modifierFlags & 1) { - transformFlags |= 3 | 768; - } + transformFlags = subtreeFlags | 268435456; if (modifierFlags & 2270 || node.typeParameters || node.type) { transformFlags |= 3; } if (modifierFlags & 256) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17733,54 +18393,63 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (ts.hasModifier(node, 2270) || node.typeParameters || node.type) { transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 32768) { - transformFlags |= 65536; + if (subtreeFlags & 262144) { + transformFlags |= 524288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592227669; + return transformFlags & ~979719509; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; if (expressionKind === 96) { - transformFlags |= 32768; + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 168 || nameKind === 169) { - transformFlags |= 768 | 8388608; + if (nameKind === 171) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 172) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -17791,24 +18460,21 @@ var ts; } else { transformFlags = subtreeFlags; - if (modifierFlags & 1) { - transformFlags |= 768 | 3; - } - if (declarationListTransformFlags & 8388608) { - transformFlags |= 768; + if (declarationListTransformFlags & 67108864) { + transformFlags |= 3072; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 4194304 + if (subtreeFlags & 33554432 && ts.isIterationStatement(node, true)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -17816,15 +18482,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 1024) { - transformFlags |= 768; + if (node.expression.transformFlags & 16384) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -17833,26 +18499,26 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~574729557; + return transformFlags & ~839734613; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 33554432; - if (subtreeFlags & 8388608) { - transformFlags |= 768; + var transformFlags = subtreeFlags | 268435456; + if (subtreeFlags & 67108864) { + transformFlags |= 3072; } if (node.flags & 3) { - transformFlags |= 768 | 4194304; + transformFlags |= 3072 | 33554432; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536874325; + var excludeFlags = 536892757; switch (kind) { case 119: - case 185: - transformFlags |= 48; + case 188: + transformFlags |= 192; break; case 113: case 111: @@ -17860,52 +18526,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 228: + case 259: + case 181: + case 199: + case 200: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: case 245: case 246: case 247: + case 10: case 248: + case 249: + case 250: + case 251: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 212: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 193: + case 180: + case 257: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 194: + transformFlags |= 3072 | 134217728; break; case 118: - case 131: - case 128: - case 133: - case 121: + case 132: + case 129: case 134: + case 121: + case 135: case 104: - case 142: - case 145: - case 147: - case 152: + case 143: + case 146: + case 148: case 153: case 154: case 155: @@ -17919,122 +18582,138 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 226: + case 227: case 167: + case 168: + case 169: + case 170: transformFlags = 3; excludeFlags = -3; break; - case 141: - transformFlags |= 2097152; - if (subtreeFlags & 32768) { - transformFlags |= 131072; + case 142: + transformFlags |= 16777216; + if (subtreeFlags & 262144) { + transformFlags |= 1048576; } break; - case 192: - transformFlags |= 1048576; + case 195: + case 258: + transformFlags |= 8388608; break; + case 173: + if (node.dotDotDotToken) { + transformFlags |= 8388608; + } case 96: - transformFlags |= 768; + transformFlags |= 3072; break; case 98: - transformFlags |= 32768; - break; - case 168: - case 169: - transformFlags |= 768 | 8388608; - break; - case 144: - transformFlags |= 3 | 8192; - break; - case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; - } - if (subtreeFlags & 131072) { - transformFlags |= 32768; - } + transformFlags |= 262144; break; case 171: - case 176: - excludeFlags = 537922901; + case 172: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; + } + else { + transformFlags |= 3072 | 67108864; + } + break; + case 145: + transformFlags |= 3 | 65536; + break; + case 175: + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + break; + case 174: + case 179: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 205: - case 206: - case 207: case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; - } - break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 260: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 215: + case 213: + case 214: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { + if (kind >= 156 && kind <= 170) { return -3; } switch (kind) { - case 175: - case 176: - case 171: - return 537922901; - case 226: - return 574729557; - case 143: - return 545262933; - case 181: - return 592227669; - case 180: - case 221: - return 592293205; - case 220: - return 545262933; - case 222: - case 193: - return 539749717; - case 149: - return 591760725; - case 148: + case 178: + case 179: + case 174: + return 545281365; + case 229: + return 839734613; + case 144: + return 604001621; + case 184: + return 979719509; + case 183: + case 224: + return 980243797; + case 223: + return 604001621; + case 225: + case 196: + return 559895893; case 150: + return 975983957; + case 149: case 151: - return 591760725; - case 118: - case 131: - case 128: - case 133: - case 121: - case 134: - case 104: - case 142: - case 145: - case 147: case 152: + return 975983957; + case 118: + case 132: + case 129: + case 134: + case 121: + case 135: + case 104: + case 143: + case 146: + case 148: case 153: case 154: - case 223: - case 224: + case 155: + case 226: + case 227: return -3; - case 172: - return 539110741; + case 175: + return 554784085; default: - return 536874325; + return 536892757; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -18049,24 +18728,50 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2: + case 0: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -18075,18 +18780,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -18097,7 +18790,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -18122,11 +18814,11 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { + var parent_6 = ts.getDirectoryPath(currentDirectory); + if (parent_6 === currentDirectory) { break; } - currentDirectory = parent_7; + currentDirectory = parent_6; } return typeRoots; } @@ -18136,7 +18828,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -18163,18 +18854,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -18186,15 +18876,12 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -18210,9 +18897,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -18225,8 +18910,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -18281,15 +18966,15 @@ var ts; return result; } ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -18323,7 +19008,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -18340,7 +19025,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -18351,7 +19036,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -18378,9 +19063,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -18390,53 +19075,63 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0) || tryResolve(1); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -18446,19 +19141,28 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { var directory = ts.getDirectoryPath(candidate); if (directory) { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { @@ -18482,18 +19186,21 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -18503,85 +19210,76 @@ var ts; } failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(0, moduleName, directory, failedLookupLocations, state, false, true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); + var resolved = tryResolve(0) || tryResolve(1); + return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -18592,6 +19290,18 @@ var ts; containingDirectory = parentPath; } } + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0, moduleName, globalCache, failedLookupLocations, state, true) || + loadModuleFromNodeModules(1, moduleName, globalCache, failedLookupLocations, state, true); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); var ts; (function (ts) { @@ -18679,7 +19389,10 @@ var ts; getAmbientModules: getAmbientModules, getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter + isOptionalParameter: isOptionalParameter, + tryFindAmbientModuleWithoutAugmentations: function (moduleName) { + return tryFindAmbientModule(moduleName, false); + } }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -18693,9 +19406,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 524288, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 524288, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -18705,11 +19418,15 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + emptyTypeLiteralSymbol.members = ts.createMap(); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - anyFunctionType.flags |= 2097152; + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -18797,6 +19514,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -18817,6 +19536,21 @@ var ts; builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); return checker; + function getJsxNamespace() { + if (_jsxNamespace === undefined) { + _jsxNamespace = "React"; + if (compilerOptions.jsxFactory) { + _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + if (_jsxFactoryEntity) { + _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text; + } + } + else if (compilerOptions.reactNamespace) { + _jsxNamespace = compilerOptions.reactNamespace; + } + } + return _jsxNamespace; + } function getEmitResolver(sourceFile, cancellationToken) { getDiagnostics(sourceFile, cancellationToken); return emitResolver; @@ -18897,7 +19631,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 229 && source.valueDeclaration.kind !== 229))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -18953,7 +19687,7 @@ var ts; var moduleNotFoundError = !ts.isInAmbientContext(moduleName.parent.parent) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; - var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError); + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true); if (!mainModule) { return; } @@ -18994,7 +19728,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 260 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -19038,7 +19772,7 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 222 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -19046,17 +19780,17 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 204: + case 210: + case 212: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 211: + case 212: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -19073,7 +19807,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 146 && + current.parent.kind === 147 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -19096,18 +19830,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 277) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 143 || - lastLocation.kind === 142 + lastLocation.kind === 144 || + lastLocation.kind === 143 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 143 || + lastLocation.kind === 144 || (lastLocation === location.type && - result.valueDeclaration.kind === 143); + result.valueDeclaration.kind === 144); } } if (useResult) { @@ -19119,13 +19853,13 @@ var ts; } } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 229: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 260 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -19135,7 +19869,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 242)) { break; } } @@ -19143,13 +19877,13 @@ var ts; break loop; } break; - case 225: + case 228: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 147: case 146: - case 145: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -19159,9 +19893,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 225: + case 196: + case 226: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -19169,7 +19903,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 196 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -19177,28 +19911,28 @@ var ts; } } break; - case 141: + case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 223) { + if (ts.isClassLike(grandparent) || grandparent.kind === 226) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 181: + case 152: + case 224: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 183: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -19211,8 +19945,8 @@ var ts; } } break; - case 144: - if (location.parent && location.parent.kind === 143) { + case 145: + if (location.parent && location.parent.kind === 144) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -19254,7 +19988,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 229) { + if (decls && decls.length === 1 && decls[0].kind === 232) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -19301,9 +20035,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 176: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 198: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -19324,7 +20058,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 222), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -19341,10 +20075,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 234) { node = node.parent; } return node; @@ -19354,7 +20088,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 241) { + if (node.moduleReference.kind === 244) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -19415,28 +20149,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_13 = specifier.propertyName || specifier.name; - if (name_13.text) { + var name_17 = specifier.propertyName || specifier.name; + if (name_17.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); + error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); } return symbol; } @@ -19458,19 +20192,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: - return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); case 233: - return getTargetOfNamespaceImport(node); + return getTargetOfImportEqualsDeclaration(node); case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node); case 236: + return getTargetOfNamespaceImport(node); + case 238: + return getTargetOfImportSpecifier(node); + case 242: + return getTargetOfExportSpecifier(node); + case 239: return getTargetOfExportAssignment(node); - case 229: + case 232: return getTargetOfNamespaceExportDeclaration(node); } } @@ -19514,10 +20248,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 239) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 242) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -19529,11 +20263,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 140) { + if (entityName.kind === 70 || entityName.parent.kind === 141) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 230); + ts.Debug.assert(entityName.parent.kind === 233); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -19552,9 +20286,9 @@ var ts; return undefined; } } - else if (name.kind === 140 || name.kind === 173) { - var left = name.kind === 140 ? name.left : name.expression; - var right = name.kind === 140 ? name.right : name.name; + else if (name.kind === 141 || name.kind === 176) { + var left = name.kind === 141 ? name.left : name.expression; + var right = name.kind === 141 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -19579,27 +20313,28 @@ var ts; function resolveExternalModuleName(location, moduleReferenceExpression) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); } - function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral); + return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); } - function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode) { + function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } var moduleName = ts.escapeIdentifier(moduleReference); if (moduleName === undefined) { return; } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); - if (symbol) { - return getMergedSymbol(symbol); - } + var ambientModule = tryFindAmbientModule(moduleName, true); + if (ambientModule) { + return ambientModule; } + var isRelative = ts.isExternalModuleNameRelative(moduleName); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); + var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return getMergedSymbol(sourceFile.symbol); @@ -19615,14 +20350,30 @@ var ts; return getMergedSymbol(pattern.symbol); } } + if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (isForAugmentation) { + ts.Debug.assert(!!moduleNotFoundError); + var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; + error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + } + else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + } + return undefined; + } if (moduleNotFoundError) { - var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); - if (tsExtension) { - var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + if (resolutionDiagnostic) { + error(errorNode, resolutionDiagnostic, moduleName, resolvedModule.resolvedFileName); } else { - error(errorNode, moduleNotFoundError, moduleName); + var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } } return undefined; @@ -19737,7 +20488,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 149 && ts.nodeIsPresent(member.body)) { + if (member.kind === 150 && ts.nodeIsPresent(member.body)) { return member; } } @@ -19808,11 +20559,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 229: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -19845,7 +20596,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -19876,7 +20627,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -19890,10 +20641,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 146: - case 148: - case 150: + case 147: + case 149: case 151: + case 152: continue; default: return false; @@ -19949,7 +20700,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 260 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -19983,11 +20734,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 140 || entityName.kind === 173 || - entityName.parent.kind === 230) { + else if (entityName.kind === 141 || entityName.kind === 176 || + entityName.parent.kind === 233) { meaning = 1920; } else { @@ -20079,10 +20830,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 165) { + while (node.kind === 166) { node = node.parent; } - if (node.kind === 224) { + if (node.kind === 227) { return getSymbolOfNode(node); } } @@ -20090,7 +20841,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 230 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -20104,10 +20855,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 196: return "(Anonymous class)"; - case 180: - case 181: + case 183: + case 184: return "(Anonymous function)"; } } @@ -20159,9 +20910,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -20213,9 +20964,7 @@ var ts; else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && - (getObjectFlags(type) & 16 && !type.target || type.flags & 196608) && - type.aliasSymbol && + else if (!(flags & 512) && (getObjectFlags(type) & 16 || type.flags & 196608) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -20229,6 +20978,17 @@ var ts; else if (type.flags & 96) { writer.writeStringLiteral(literalTypeToString(type)); } + else if (type.flags & 262144) { + writer.writeKeyword("keyof"); + writeSpace(writer); + writeType(type.type, 64); + } + else if (type.flags & 524288) { + writeType(type.objectType, 64); + writePunctuation(writer, 20); + writeType(type.indexType, 0); + writePunctuation(writer, 21); + } else { writePunctuation(writer, 16); writeSpace(writer); @@ -20285,12 +21045,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -20324,7 +21084,7 @@ var ts; } else if (ts.contains(symbolStack, symbol)) { var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias && !type.target) { + if (typeAlias) { buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { @@ -20349,7 +21109,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 227; + return declaration.parent.kind === 260 || declaration.parent.kind === 230; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -20365,7 +21125,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -20383,7 +21143,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -20439,6 +21199,12 @@ var ts; writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, 17); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); @@ -20451,8 +21217,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 133); - writeIndexSignature(resolved.numberIndexInfo, 131); + writeIndexSignature(resolved.stringIndexInfo, 134); + writeIndexSignature(resolved.numberIndexInfo, 132); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -20475,9 +21241,6 @@ var ts; writer.writeLine(); } } - writer.decreaseIndent(); - writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -20515,12 +21278,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -20534,7 +21297,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 173); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -20662,63 +21425,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 173: return isDeclarationVisible(node.parent.parent); - case 219: + case 222: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: + case 229: case 225: - case 230: + case 226: + case 227: + case 224: + case 228: + case 233: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_9 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 233 && parent_9.kind !== 260 && ts.isInAmbientContext(parent_9))) { + return isGlobalSourceFile(parent_9); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_9); case 147: + case 146: + case 151: + case 152: + case 149: + case 148: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 149: - case 153: - case 152: + case 150: case 154: - case 143: - case 227: - case 157: + case 153: + case 155: + case 144: + case 230: case 158: - case 160: - case 156: + case 159: case 161: + case 157: case 162: case 163: case 164: case 165: + case 166: return isDeclarationVisible(node.parent); - case 232: - case 233: case 235: - return false; - case 142: - case 256: - case 229: - return true; case 236: + case 238: + return false; + case 143: + case 260: + case 232: + return true; + case 239: return false; default: return false; @@ -20727,10 +21490,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 239) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 239) { + else if (node.parent.kind === 242) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -20808,12 +21571,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: + case 222: + case 223: + case 238: + case 237: + case 236: case 235: - case 234: - case 233: - case 232: node = node.parent; break; default: @@ -20839,22 +21602,30 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70: - return name.text; - case 9: - case 8: - return name.text; - case 141: - if (ts.isStringOrNumericLiteral(name.expression.kind)) { - return name.expression.text; - } - } - return undefined; - } function isComputedNonLiteralName(name) { - return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression.kind); + } + function getRestType(source, properties, symbol) { + ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + var members = ts.createMap(); + var names = ts.createMap(); + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var name_18 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_18)] = true; + } + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + var inNamesToRemove = prop.name in names; + var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); + var isMethod = prop.flags & 8192; + var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); + if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + members[prop.name] = prop; + } + } + var stringIndexInfo = getIndexInfoOfType(source, 0); + var numberIndexInfo = getIndexInfoOfType(source, 1); + return createAnonymousType(symbol, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -20869,26 +21640,45 @@ var ts; return parentType; } var type; - if (pattern.kind === 168) { - var name_14 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_14)) { - return anyType; + if (pattern.kind === 171) { + if (declaration.dotDotDotToken) { + if (!(parentType.flags & 32768)) { + error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); + return unknownType; + } + var literalMembers = []; + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 197 && !element.dotDotDotToken) { + literalMembers.push(element.propertyName || element.name); + } + } + type = getRestType(parentType, literalMembers, declaration.symbol); } - if (declaration.initializer) { - getContextualType(declaration.initializer); - } - var text = getTextOfPropertyName(name_14); - type = getTypeOfPropertyOfType(parentType, text) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); - return unknownType; + else { + var name_19 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_19)) { + return anyType; + } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } + var text = ts.getTextOfPropertyName(name_19); + type = getTypeOfPropertyOfType(parentType, text) || + isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || + getIndexTypeOfType(parentType, 0); + if (!type) { + error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); + return unknownType; + } } } else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); - if (!declaration.dotDotDotToken) { + if (declaration.dotDotDotToken) { + type = createArrayType(elementType); + } + else { var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -20903,9 +21693,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -20925,15 +21712,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 219 && - declaration.parent.kind === 220 && - declaration.parent.parent.kind === 201) { + if (declaration.kind === 222 && + declaration.parent.kind === 223 && + declaration.parent.parent.kind === 204) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 143) { + else if (declaration.kind === 144) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -20947,22 +21734,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 174 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 211) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 212) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -20971,7 +21758,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + if (declaration.kind === 222 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -20980,10 +21767,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var func = declaration.parent; - if (func.kind === 151 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); + if (func.kind === 152 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -21009,7 +21796,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 257) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -21034,11 +21821,11 @@ var ts; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { + if (isComputedNonLiteralName(name) || e.dotDotDotToken) { hasComputedProperties = true; return; } - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -21069,7 +21856,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 171 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -21079,7 +21866,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 256) { return type; } return getWidenedType(type); @@ -21094,7 +21881,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 143 ? root.parent : root; + var memberDeclaration = root.kind === 144 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -21107,25 +21894,25 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 239) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 284 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 188 || - declaration.kind === 173 && declaration.parent.kind === 188) { - if (declaration.flags & 1048576) { + if (declaration.kind === 191 || + declaration.kind === 176 && declaration.parent.kind === 191) { + if (declaration.flags & 2097152) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 191 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -21151,7 +21938,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -21171,9 +21958,9 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 150); - var setter = ts.getDeclarationOfKind(symbol, 151); - if (getter && getter.flags & 1048576) { + var getter = ts.getDeclarationOfKind(symbol, 151); + var setter = ts.getDeclarationOfKind(symbol, 152); + if (getter && getter.flags & 2097152) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -21213,7 +22000,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 150); + var getter_1 = ts.getDeclarationOfKind(symbol, 151); error(getter_1, 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)); } } @@ -21224,7 +22011,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -21309,9 +22096,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 222 || node.kind === 193 || - node.kind === 221 || node.kind === 180 || - node.kind === 148 || node.kind === 181) { + if (node.kind === 225 || node.kind === 196 || + node.kind === 224 || node.kind === 183 || + node.kind === 149 || node.kind === 184) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -21320,15 +22107,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 226); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 223 || node.kind === 222 || - node.kind === 193 || node.kind === 224) { + if (node.kind === 226 || node.kind === 225 || + node.kind === 196 || node.kind === 227) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -21454,7 +22241,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 226 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -21483,7 +22270,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223) { + if (declaration.kind === 226) { if (declaration.flags & 64) { return false; } @@ -21534,7 +22321,7 @@ var ts; return unknownType; } var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 283); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -21545,7 +22332,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); + declaration = ts.getDeclarationOfKind(symbol, 227); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -21569,14 +22356,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8 || expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -21604,7 +22391,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -21642,7 +22429,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 142).constraint) { + if (!ts.getDeclarationOfKind(symbol, 143).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -21692,19 +22479,19 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 167: + case 129: + case 170: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -21713,7 +22500,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -21729,12 +22516,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 146: - case 145: - return isIndependentVariableLikeDeclaration(declaration); - case 148: case 147: + case 146: + return isIndependentVariableLikeDeclaration(declaration); case 149: + case 148: + case 150: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -21800,8 +22587,8 @@ var ts; else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); + constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } @@ -21863,7 +22650,7 @@ var ts; var baseSig = baseSignatures_1[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -21956,6 +22743,9 @@ var ts; function intersectIndexInfos(info1, info2) { return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); } + function unionSpreadIndexInfos(info1, info2) { + return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; @@ -21974,8 +22764,8 @@ var ts; var symbol = type.symbol; if (type.target) { var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); - var callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); - var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper); var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper); var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -22076,7 +22866,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 196608 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -22089,22 +22881,13 @@ var ts; return type.resolvedApparentType; } function getApparentType(type) { - if (type.flags & 16384) { - type = getApparentTypeOfTypeParameter(type); - } - if (type.flags & 34) { - type = globalStringType; - } - else if (type.flags & 340) { - type = globalNumberType; - } - else if (type.flags & 136) { - type = globalBooleanType; - } - else if (type.flags & 512) { - type = getGlobalESSymbolType(); - } - return type; + var t = type.flags & 16384 ? getApparentTypeOfTypeParameter(type) : type; + return t.flags & 34 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 262144 ? stringOrNumberType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -22245,7 +23028,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -22273,8 +23056,8 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 1048576) { - if (node.type && node.type.kind === 268) { + if (node.flags & 2097152) { + if (node.type && node.type.kind === 272) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -22283,11 +23066,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 272; } } } } + function tryFindAmbientModule(moduleName, withAugmentations) { + if (ts.isExternalModuleNameRelative(moduleName)) { + return undefined; + } + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; + } function isOptionalParameter(node) { if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) { return true; @@ -22341,7 +23131,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 170) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -22353,10 +23143,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 150 || declaration.kind === 151) && + if ((declaration.kind === 151 || declaration.kind === 152) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 150 ? 151 : 150; + var otherKind = declaration.kind === 151 ? 152 : 151; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -22368,14 +23158,14 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - var classType = declaration.kind === 149 ? + var classType = declaration.kind === 150 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 155 ? + var typePredicate = declaration.type && declaration.type.kind === 156 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -22392,14 +23182,14 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 151); + if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 152); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -22413,20 +23203,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 269: + case 152: + case 183: + case 184: + case 273: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -22494,6 +23284,11 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); + var id = getTypeListId(typeArguments); + return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + } + function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { @@ -22506,7 +23301,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -22520,7 +23315,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 131 : 133; + var syntaxKind = kind === 1 ? 132 : 134; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -22547,7 +23342,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 142).constraint; + return ts.getDeclarationOfKind(type.symbol, 143).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -22580,7 +23375,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); } function getTypeListId(types) { var result = ""; @@ -22613,7 +23408,7 @@ var ts; result |= type.flags; } } - return result & 3670016; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -22681,11 +23476,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 271: return node.name; - case 195: + case 198: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -22709,7 +23504,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 271) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -22719,13 +23514,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 271) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 156 + var typeNameOrExpression = node.kind === 157 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -22754,9 +23549,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 222: - case 223: case 225: + case 226: + case 228: return declaration; } } @@ -22894,7 +23689,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 524288)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -22970,7 +23765,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 262144 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -23047,14 +23842,14 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var _loop_1 = function (i) { + var _loop_2 = function (i) { var type_1 = types[i]; if (type_1.flags & 65536) { return { value: getUnionType(ts.map(type_1.types, function (t) { return getIntersectionType(ts.replaceElement(types, i, t)); }), false, aliasSymbol, aliasTypeArguments) }; } }; for (var i = 0; i < types.length; i++) { - var state_2 = _loop_1(i); + var state_2 = _loop_2(i); if (typeof state_2 === "object") return state_2.value; } @@ -23084,25 +23879,215 @@ var ts; } return links.resolvedType; } + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return ts.startsWith(prop.name, "__@") ? neverType : getLiteralTypeForText(32, ts.unescapeIdentifier(prop.name)); + } + function getLiteralTypeFromPropertyNames(type) { + return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName)); + } + function getIndexType(type) { + return type.flags & 16384 ? getIndexTypeForTypeParameter(type) : + type.flags & 1 || getIndexInfoOfType(type, 0) ? stringOrNumberType : + getIndexInfoOfType(type, 1) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getLiteralTypeFromPropertyNames(type); + } + function getTypeFromTypeOperatorNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexType(getTypeFromTypeNodeNoAlias(node.type)); + } + return links.resolvedType; + } + function createIndexedAccessType(objectType, indexType) { + var type = createType(524288); + type.objectType = objectType; + type.indexType = indexType; + return type; + } + function getIndexedAccessTypeForTypeParameter(objectType, indexType) { + var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); + return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); + } + function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { + var accessExpression = accessNode && accessNode.kind === 177 ? accessNode : undefined; + var propName = indexType.flags & (32 | 64 | 256) ? + indexType.text : + accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? + ts.getPropertyNameForKnownSymbolName(accessExpression.argumentExpression.name.text) : + undefined; + if (propName) { + var prop = getPropertyOfType(objectType, propName); + if (prop) { + if (accessExpression) { + if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { + error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); + return unknownType; + } + if (cacheSymbol) { + getNodeLinks(accessNode).resolvedSymbol = prop; + } + } + return getTypeOfSymbol(prop); + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512)) { + if (isTypeAny(objectType)) { + return anyType; + } + var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340) && getIndexInfoOfType(objectType, 1) || + getIndexInfoOfType(objectType, 0) || + undefined; + if (indexInfo) { + if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + return unknownType; + } + return indexInfo.type; + } + if (accessExpression && !isConstEnumObjectType(objectType)) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (getIndexTypeOfType(objectType, 1)) { + error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } + } + return anyType; + } + } + if (accessNode) { + var indexNode = accessNode.kind === 177 ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (32 | 64)) { + error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); + } + else if (indexType.flags & (2 | 4)) { + error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); + } + else { + error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); + } + } + return unknownType; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + if (indexType.flags & 16384) { + if (!isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + if (accessNode) { + error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); + } + return unknownType; + } + return getIndexedAccessTypeForTypeParameter(objectType, indexType); + } + var apparentType = getApparentType(objectType); + if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + var propTypes = []; + for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, false); + if (propType === unknownType) { + return unknownType; + } + propTypes.push(propType); + } + return getUnionType(propTypes); + } + return getPropertyTypeForIndexType(apparentType, indexType, accessNode, true); + } + function getTypeFromIndexedAccessTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexedAccessType(getTypeFromTypeNodeNoAlias(node.objectType), getTypeFromTypeNodeNoAlias(node.indexType), node); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(16, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; - links.resolvedType = type; + if (ts.isEmpty(node.symbol.members) && !aliasSymbol && !aliasTypeArguments) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = type; + } } return links.resolvedType; } + function getSpreadType(left, right, isFromObjectLiteral) { + ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); + if (left.flags & 1 || right.flags & 1) { + return anyType; + } + var members = ts.createMap(); + var skippedPrivateMembers = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + if (left === emptyObjectType) { + stringIndexInfo = getIndexInfoOfType(right, 0); + numberIndexInfo = getIndexInfoOfType(right, 1); + } + else { + stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0)); + numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1)); + } + for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { + var rightProp = _a[_i]; + var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; + var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { + skippedPrivateMembers[rightProp.name] = true; + } + else if (isOwnProperty && !isSetterWithoutGetter) { + members[rightProp.name] = rightProp; + } + } + for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { + var leftProp = _c[_b]; + if (leftProp.flags & 65536 && !(leftProp.flags & 32768) + || leftProp.name in skippedPrivateMembers) { + continue; + } + if (leftProp.name in members) { + var rightProp = members[leftProp.name]; + var rightType = getTypeOfSymbol(rightProp); + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); + var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var result = createSymbol(flags, leftProp.name); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); + result.leftSpread = leftProp; + result.rightSpread = rightProp; + result.declarations = declarations; + result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); + members[leftProp.name] = result; + } + } + else { + members[leftProp.name] = leftProp; + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 && !(type.flags & 262144)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 262144, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -23111,7 +24096,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 262144 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -23143,9 +24128,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 226)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -23165,79 +24150,83 @@ var ts; function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { case 118: - case 258: - case 259: + case 262: + case 263: return anyType; - case 133: + case 134: return stringType; - case 131: + case 132: return numberType; case 121: return booleanType; - case 134: + case 135: return esSymbolType; case 104: return voidType; - case 136: + case 137: return undefinedType; case 94: return nullType; - case 128: + case 129: return neverType; - case 283: + case 287: return nullType; - case 284: + case 288: return undefinedType; - case 285: + case 289: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 170: return getTypeFromLiteralTypeNode(node); - case 282: + case 286: return getTypeFromLiteralTypeNode(node.literal); - case 156: - case 267: - return getTypeFromTypeReference(node); - case 155: - return booleanType; - case 195: - return getTypeFromTypeReference(node); - case 159: - return getTypeFromTypeQueryNode(node); - case 161: - case 260: - return getTypeFromArrayTypeNode(node); - case 162: - return getTypeFromTupleTypeNode(node); - case 163: - case 261: - return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 165: - case 263: - case 264: - case 271: - case 272: - case 268: - return getTypeFromTypeNode(node.type); - case 265: - return getTypeFromTypeNode(node.literal); case 157: - case 158: + case 271: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 198: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 264: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 265: + return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 166: + case 267: + case 268: + case 275: + case 276: + case 272: + return getTypeFromTypeNode(node.type); case 269: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 285: + case 273: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 266: return getTypeFromJSDocTupleType(node); - case 270: + case 274: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -23254,6 +24243,12 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -23276,7 +24271,6 @@ var ts; count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; - mapper.targetTypes = targets; return mapper; } function createTypeEraser(sources) { @@ -23379,32 +24373,35 @@ var ts; result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); mapper.instantiations[type.id] = result; return result; } function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { + if (!(symbol.declarations && symbol.declarations.length)) { + return false; + } var mappedTypes = mapper.mappedTypes; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 222: - case 193: - case 223: - case 224: + case 152: + case 183: + case 184: + case 225: + case 196: + case 226: + case 227: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -23414,15 +24411,15 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 226) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 229: + case 260: return false; } node = node.parent; @@ -23442,14 +24439,20 @@ var ts; instantiateAnonymousType(type, mapper) : type; } if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (type.flags & 131072) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } } return type; @@ -23458,27 +24461,27 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 180: - case 181: + case 183: + case 184: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 175: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 174: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 192: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 191: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 256: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 182: return isContextSensitive(node.expression); } return false; @@ -23490,7 +24493,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 184) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -23739,10 +24742,10 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { @@ -23755,7 +24758,7 @@ var ts; return related === 1; } } - if (source.flags & 245760 || target.flags & 245760) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -23792,9 +24795,15 @@ var ts; targetType = typeToString(target, undefined, 128); } if (!message) { - message = relation === comparableRelation ? - ts.Diagnostics.Type_0_is_not_comparable_to_type_1 : - ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + if (relation === comparableRelation) { + message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1; + } + else if (sourceType === targetType) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; + } + else { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + } } reportError(message, sourceType, targetType); } @@ -23810,10 +24819,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -23823,7 +24832,7 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (getObjectFlags(source) & 64 && source.flags & 262144) { + if (getObjectFlags(source) & 64 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -23861,6 +24870,22 @@ var ts; return result; } } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + } + } + else if (target.flags & 262144) { + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } if (source.flags & 16384) { var constraint = getConstraintOfTypeParameter(source); if (!constraint || constraint.flags & 1) { @@ -24125,8 +25150,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 64); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var targetProp = properties_3[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -24563,8 +25588,8 @@ var ts; type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 262144 ? stringType : - type.flags & 64 && type.flags & 262144 ? numberType : + return type.flags & 32 && type.flags & 1048576 ? stringType : + type.flags & 64 && type.flags & 1048576 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : @@ -24643,7 +25668,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(getObjectFlags(type) & 64 && type.flags & 262144)) { + if (!(getObjectFlags(type) & 64 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -24653,7 +25678,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~262144; + regularNew.flags = resolved.flags & ~1048576; regularNew.objectFlags |= 64; type.regularType = regularNew; return regularNew; @@ -24671,7 +25696,7 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 1572864) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } @@ -24709,7 +25734,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 524288) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -24723,25 +25748,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 147: case 146: - case 145: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 143: + case 144: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 170: + case 173: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 224: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 183: + case 184: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -24754,7 +25779,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -24861,7 +25886,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 2097152) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -24948,8 +25973,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -25023,7 +26048,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 8190); + return constraint && maybeTypeOfKind(constraint, 8190 | 262144); } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; @@ -25076,10 +26101,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 159: + case 160: return true; case 70: - case 140: + case 141: node = node.parent; continue; default: @@ -25096,7 +26121,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 176) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -25107,7 +26132,7 @@ var ts; case 70: case 98: return node; - case 173: + case 176: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -25116,19 +26141,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 222 || target.kind === 173) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 176: + return target.kind === 176 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 176) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -25137,7 +26162,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 176 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -25145,7 +26170,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 176) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -25175,7 +26200,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 176 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -25286,7 +26311,7 @@ var ts; return type; } function getTypeOfDestructuredProperty(type, name) { - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || @@ -25297,19 +26322,19 @@ var ts; checkIteratedTypeOrElementType(type, undefined, false) || unknownType; } - function getTypeOfDestructuredSpreadElement(type) { + function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 171 || node.parent.kind === 253 ? + return node.parent.kind === 174 || node.parent.kind === 256 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } - function getAssignedTypeOfSpreadElement(node) { - return getTypeOfDestructuredSpreadElement(getAssignedType(node.parent)); + function getAssignedTypeOfSpreadExpression(node) { + return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent)); } function getAssignedTypeOfPropertyAssignment(node) { return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name); @@ -25320,21 +26345,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 211: return stringType; - case 209: + case 212: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: + case 191: return getAssignedTypeOfBinaryExpression(parent); - case 182: + case 185: return undefinedType; - case 171: + case 174: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + case 195: + return getAssignedTypeOfSpreadExpression(parent); + case 256: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 257: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -25342,11 +26367,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 171 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : - getTypeOfDestructuredSpreadElement(parentType); + getTypeOfDestructuredSpreadExpression(parentType); return getTypeWithDefault(type, node.initializer); } function getTypeOfInitializer(node) { @@ -25357,35 +26382,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 211) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 212) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 222 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 222 || node.kind === 173 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 222 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 173 && node.parent.kind === 191 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 182: return getReferenceCandidate(node.expression); - case 188: + case 191: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -25397,13 +26422,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 179 || - parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 182 || + parent.kind === 191 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 191 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 252) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -25521,11 +26546,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || - parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 174 && + var isLengthPushOrUnshift = parent.kind === 176 && (parent.name.text === "length" || + parent.parent.kind === 178 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 177 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 191 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -25534,7 +26559,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 246783)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -25544,7 +26569,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 128 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 200 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -25589,7 +26614,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 173) { + if (container && container !== flowContainer && reference.kind !== 176) { flow = container.flowNode; continue; } @@ -25609,7 +26634,7 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 186 || node.parent.kind === 187) { + if (ts.getAssignmentTargetKind(node) === 2) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -25632,7 +26657,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 178 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -25640,7 +26665,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 128) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 178) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -25758,7 +26783,7 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && + return expr.kind === 176 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -25792,10 +26817,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 === 183 && right_1.kind === 9) { + if (left_1.kind === 186 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 183 && left_1.kind === 9) { + if (right_1.kind === 186 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -25972,10 +26997,10 @@ var ts; } } else { - var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { + var invokedExpression = ts.skipParentheses(callExpression.expression); + if (invokedExpression.kind === 177 || invokedExpression.kind === 176) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -25990,15 +27015,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: + case 178: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179: + case 182: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 191: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 189: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -26021,19 +27046,13 @@ var ts; } return getTypeOfSymbol(symbol); } - function skipParenthesizedNodes(expression) { - while (expression.kind === 179) { - expression = expression.expression; - } - return expression; - } function getControlFlowContainer(node) { while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 227 || - node.kind === 256 || - node.kind === 146) { + node.kind === 230 || + node.kind === 260 || + node.kind === 147) { return node; } } @@ -26064,7 +27083,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { symbol.isAssigned = true; } } @@ -26078,19 +27097,23 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return unknownType; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 181) { + if (container.kind === 184) { 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.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 262144) { + if (node.flags & 524288) { getNodeLinks(container).flags |= 8192; } + return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -26099,7 +27122,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 225 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -26111,11 +27134,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 196) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 146 && ts.hasModifier(container, 32)) { + if (container.kind === 147 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -26130,15 +27153,26 @@ var ts; checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; - if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (!(localOrExportSymbol.flags & 3)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + return unknownType; + } + if (isReadonlySymbol(localOrExportSymbol)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); + return unknownType; + } + } + if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 143; + var isParameter = ts.getRootDeclaration(declaration).kind === 144; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || - flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 183 || + flowContainer.kind === 184 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -26159,7 +27193,7 @@ var ts; error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } - return flowType; + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { var current = node; @@ -26174,7 +27208,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 255) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -26192,8 +27226,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 210 && + ts.getAncestor(symbol.valueDeclaration, 223).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -26205,14 +27239,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 182) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 186 || current.parent.kind === 187)) { + else if ((current.parent.kind === 189 || current.parent.kind === 190)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -26231,7 +27265,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 146 || container.kind === 149) { + if (container.kind === 147 || container.kind === 150) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -26265,7 +27299,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 149) { + if (container.kind === 150) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -26275,29 +27309,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 184) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 229: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 228: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 149: + case 150: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 147: case 146: - case 145: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 141: + case 142: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -26306,7 +27340,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 183 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -26341,27 +27375,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 269) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 273) { var jsDocFunctionType = typeTag.typeExpression.type; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 272) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 276) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 143) { + if (n.kind === 144) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 178 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 184) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -26370,16 +27404,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 141) { + while (current && current !== container && current.kind !== 142) { current = current.parent; } - if (current && current.kind === 141) { + if (current && current.kind === 142) { 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 === 172)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 175)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -26394,7 +27428,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 148 && ts.getModifierFlags(container) & 256) { + if (container.kind === 149 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -26405,7 +27439,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 175) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -26423,7 +27457,7 @@ var ts; } return unknownType; } - if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -26435,24 +27469,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 149; + return container.kind === 150; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 172) { + if (ts.isClassLike(container.parent) || container.parent.kind === 175) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || - container.kind === 151; + return container.kind === 149 || + container.kind === 148 || + container.kind === 151 || + container.kind === 152; } else { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || + return container.kind === 149 || + container.kind === 148 || container.kind === 151 || + container.kind === 152 || + container.kind === 147 || container.kind === 146 || - container.kind === 145 || - container.kind === 149; + container.kind === 150; } } } @@ -26460,7 +27494,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 184) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -26516,7 +27550,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -26527,11 +27561,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_15 = declaration.propertyName || declaration.name; + var name_20 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_15)) { - var text = getTextOfPropertyName(name_15); + !ts.isBindingPattern(name_20)) { + var text = ts.getTextOfPropertyName(name_20); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -26568,7 +27602,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 143 && node.parent.initializer === node) { + if (node.parent.kind === 144 && node.parent.initializer === node) { return true; } node = node.parent; @@ -26577,8 +27611,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 149 || - functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { + functionDecl.kind === 150 || + functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -26597,7 +27631,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 180) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -26705,13 +27739,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 249) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 250) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -26729,41 +27763,41 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 170: + case 173: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 184: + case 215: return getContextualTypeForReturnExpression(node); - case 191: + case 194: return getContextualTypeForYieldOperand(parent); - case 175: - case 176: - return getContextualTypeForArgument(parent, node); case 178: - case 196: - return getTypeFromTypeNode(parent.type); - case 188: - return getContextualTypeForBinaryOperand(node); - case 253: - case 254: - return getContextualTypeForObjectLiteralElement(parent); - case 171: - return getContextualTypeForElementExpression(node); - case 189: - return getContextualTypeForConditionalOperand(node); - case 198: - ts.Debug.assert(parent.parent.kind === 190); - return getContextualTypeForSubstitutionExpression(parent.parent, node); case 179: + return getContextualTypeForArgument(parent, node); + case 181: + case 199: + return getTypeFromTypeNode(parent.type); + case 191: + return getContextualTypeForBinaryOperand(node); + case 256: + case 257: + return getContextualTypeForObjectLiteralElement(parent); + case 174: + return getContextualTypeForElementExpression(node); + case 192: + return getContextualTypeForConditionalOperand(node); + case 201: + ts.Debug.assert(parent.parent.kind === 193); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 182: return getContextualType(parent); - case 248: + case 251: return getContextualType(parent); - case 246: - case 247: + case 249: + case 250: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -26792,7 +27826,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 183 || node.kind === 184; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -26805,7 +27839,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -26841,13 +27875,13 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper.context; } - function checkSpreadElementExpression(node, contextualMapper) { + function checkSpreadExpression(node, contextualMapper) { var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 170 && !!node.initializer) || - (node.kind === 188 && node.operatorToken.kind === 57); + return (node.kind === 173 && !!node.initializer) || + (node.kind === 191 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -26856,7 +27890,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 192) { + if (inDestructuringPattern && e.kind === 195) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -26868,7 +27902,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 195; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -26879,7 +27913,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { + if (pattern && (pattern.kind === 172 || pattern.kind === 174)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -26887,7 +27921,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 197) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -26904,7 +27938,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -26946,9 +27980,11 @@ var ts; checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); var propertiesArray = []; + var spread = emptyObjectType; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); + (contextualType.pattern.kind === 171 || contextualType.pattern.kind === 175); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -26956,25 +27992,25 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 253 || - memberDecl.kind === 254 || + if (memberDecl.kind === 256 || + memberDecl.kind === 257 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 256) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 148) { + else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 254); + ts.Debug.assert(memberDecl.kind === 257); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 253 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 254 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 256 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 257 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -27000,8 +28036,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 258) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + propertiesArray = []; + propertiesTable = ts.createMap(); + hasComputedStringProperty = false; + hasComputedNumberProperty = false; + typeFlags = 0; + } + var type = checkExpression(memberDecl.expression); + if (!(type.flags & (32768 | 1))) { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return unknownType; + } + spread = getSpreadType(spread, type, false); + continue; + } else { - ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); + ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -27029,19 +28082,33 @@ var ts; } } } - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 262144; - result.flags |= 1048576 | freshObjectLiteralFlag | (typeFlags & 3670016); - result.objectFlags |= 64; - if (patternWithComputedProperties) { - result.objectFlags |= 256; + if (spread !== emptyObjectType) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + } + spread.flags |= propagatedFlags; + spread.symbol = node.symbol; + return spread; } - if (inDestructuringPattern) { - result.pattern = node; + return createObjectLiteralType(); + function createObjectLiteralType() { + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + result.objectFlags |= 64; + if (patternWithComputedProperties) { + result.objectFlags |= 256; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -27058,13 +28125,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 251: checkJsxExpression(child); break; - case 242: + case 245: checkJsxElement(child); break; - case 243: + case 246: checkJsxSelfClosingElement(child); break; } @@ -27075,7 +28142,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 176 || tagName.kind === 98) { return false; } else { @@ -27091,7 +28158,7 @@ var ts; var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); + var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); if (attributeType) { correspondingPropType = attributeType; } @@ -27344,7 +28411,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); var reactRefErr = compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; + var reactNamespace = getJsxNamespace(); var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); if (reactSym) { reactSym.isReferenced = true; @@ -27356,11 +28423,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 246) { + if (node.attributes[i].kind === 249) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 250); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -27386,7 +28453,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 146; + return s.valueDeclaration ? s.valueDeclaration.kind : 147; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -27397,11 +28464,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 173 || node.kind === 219 ? + var errorNode = node.kind === 176 || node.kind === 222 ? node.name : node.right; if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -27464,6 +28531,33 @@ var ts; function checkQualifiedName(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } + function reportNonexistentProperty(propNode, containingType) { + var errorInfo; + if (containingType.flags & 65536 && !(containingType.flags & 8190)) { + for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { + var subtype = _a[_i]; + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + function markPropertyAsReferenced(prop) { + if (prop && + noUnusedIdentifiers && + (prop.flags & 106500) && + prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + if (prop.flags & 16777216) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -27480,44 +28574,29 @@ var ts; } return unknownType; } - if (noUnusedIdentifiers && - (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } + markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 173 || ts.isAssignmentTarget(node) || + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { + error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text); + return unknownType; + } + } + if (node.kind !== 176 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 65536 && !(containingType.flags & 8190)) { - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } + var flowType = getFlowTypeOfReference(node, propType, true, undefined); + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 173 + var left = node.kind === 176 ? node.expression : node.left; var type = checkExpression(left); @@ -27531,7 +28610,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 223) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -27546,14 +28625,14 @@ var ts; return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0); } function isForInVariableForNumericPropertyNames(expr) { - var e = skipParenthesizedNodes(expr); + var e = ts.skipParentheses(expr); if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 208 && + if (node.kind === 211 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -27567,9 +28646,11 @@ var ts; return false; } function checkIndexedAccess(node) { - if (!node.argumentExpression) { + var objectType = checkNonNullExpression(node.expression); + var indexExpression = node.argumentExpression; + if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 176 && node.parent.expression === node) { + if (node.parent.kind === 179 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -27579,71 +28660,17 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } + return unknownType; } - var objectType = getApparentType(checkNonNullExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); if (objectType === unknownType || objectType === silentNeverType) { return objectType; } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { + error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - if (node.argumentExpression) { - var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_16 !== undefined) { - var prop = getPropertyOfType(objectType, name_16); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - var allowedNullableFlags = strictNullChecks ? 0 : 6144; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512 | allowedNullableFlags)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexInfo = getIndexInfoOfType(objectType, 1); - if (numberIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; - return numberIndexInfo.type; - } - } - var stringIndexInfo = getIndexInfoOfType(objectType, 0); - if (stringIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; - return stringIndexInfo.type; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, getIndexTypeOfType(objectType, 1) ? - ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number : - ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; + return getIndexedAccessType(objectType, indexType, node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -27676,10 +28703,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 180) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -27701,19 +28728,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_11 = signature.declaration && signature.declaration.parent; + var parent_10 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_10 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_10; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_10; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -27730,7 +28757,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 192) { + if (arg && arg.kind === 195) { return i; } } @@ -27743,11 +28770,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 180) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 193) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -27759,7 +28786,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 144) { + else if (node.kind === 145) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -27767,7 +28794,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 179); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -27826,7 +28853,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -27873,7 +28900,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 176) { + if (thisType && thisType !== voidType && node.kind !== 179) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -27886,7 +28913,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -27901,28 +28928,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 178) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 176) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 177) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 180) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 193) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -27931,21 +28958,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 144) { + if (node.kind === 145) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return 1; - case 146: + case 147: return 2; - case 148: - case 150: + case 149: case 151: + case 152: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 143: + case 144: return 3; } } @@ -27954,48 +28981,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { return anyType; } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 141: + case 142: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -28012,20 +29039,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { return numberType; } - if (node.kind === 146) { + if (node.kind === 147) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -28046,26 +29073,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 144) { + if (node.kind === 145) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 144 || - (argIndex === 0 && node.kind === 177)) { + if (node.kind === 145 || + (argIndex === 0 && node.kind === 180)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 144) { + if (node.kind === 145) { return node.expression; } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return node.template; } else { @@ -28073,8 +29100,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 180; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -28104,7 +29131,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 178 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -28372,16 +29399,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 146: + case 147: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 148: - case 150: + case 149: case 151: + case 152: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -28408,13 +29435,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 178: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 179: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 180: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -28446,12 +29473,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 179) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 149 && - declaration.kind !== 153 && - declaration.kind !== 158 && + declaration.kind !== 150 && + declaration.kind !== 154 && + declaration.kind !== 159 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -28482,9 +29509,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 221 + ? 224 : resolvedRequire.flags & 3 - ? 219 + ? 222 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -28577,8 +29604,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 168 || - parameter.valueDeclaration.name.kind === 169)) { + (parameter.valueDeclaration.name.kind === 171 || + parameter.valueDeclaration.name.kind === 172)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -28605,7 +29632,7 @@ var ts; function createPromiseReturnType(func, promisedType) { var promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } return promiseType; @@ -28617,7 +29644,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 203) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -28696,7 +29723,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 217 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -28725,7 +29752,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 183 || func.kind === 184)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -28742,7 +29769,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 203 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -28769,9 +29796,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 180) { + if (!hasGrammarError && node.kind === 183) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -28805,14 +29832,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 148) { + if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -28822,7 +29849,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 203) { checkSourceElement(node.body); } else { @@ -28857,10 +29884,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 176 || expr.kind === 177) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 149)) + if (!(func && func.kind === 150)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -28869,44 +29896,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 176 || expr.kind === 177) { + var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 233; + return declaration && declaration.kind === 236; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { - var node = skipParenthesizedNodes(expr); - if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { + function checkReferenceExpression(expr, invalidReferenceMessage) { + var node = ts.skipParentheses(expr); + if (node.kind !== 70 && node.kind !== 176 && node.kind !== 177) { error(expr, invalidReferenceMessage); return false; } - var links = getNodeLinks(node); - var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 70 && !(symbol.flags & 3)) { - error(expr, invalidReferenceMessage); - return false; - } - if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { - error(expr, constantVariableMessage); - return false; - } - } - } - else if (node.kind === 174) { - if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { - error(expr, constantVariableMessage); - return false; - } - } return true; } function checkDeleteExpression(node) { @@ -28923,7 +29930,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 262144)) { + if (!(node.flags & 524288)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -28958,7 +29965,7 @@ var ts; case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -28971,7 +29978,7 @@ var ts; } var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -29047,29 +30054,29 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var p = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var p = properties_5[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { - if (property.kind === 253 || property.kind === 254) { - var name_17 = property.name; - if (name_17.kind === 141) { - checkComputedPropertyName(name_17); + if (property.kind === 256 || property.kind === 257) { + var name_21 = property.name; + if (name_21.kind === 142) { + checkComputedPropertyName(name_21); } - if (isComputedNonLiteralName(name_17)) { + if (isComputedNonLiteralName(name_21)) { return undefined; } - var text = getTextOfPropertyName(name_17); + var text = ts.getTextOfPropertyName(name_21); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 254) { + if (property.kind === 257) { return checkDestructuringAssignment(property, type); } else { @@ -29077,10 +30084,10 @@ var ts; } } else { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); } } - else { + else if (property.kind !== 258) { error(property, ts.Diagnostics.Property_assignment_expected); } } @@ -29095,8 +30102,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 194) { - if (element.kind !== 192) { + if (element.kind !== 197) { + if (element.kind !== 195) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -29118,11 +30125,11 @@ var ts; } else { if (elementIndex < elements.length - 1) { - error(element, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { var restExpression = element.expression; - if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 191 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -29135,7 +30142,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 257) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -29149,21 +30156,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 191 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 175) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 174) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { + if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -29174,35 +30181,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 180: + case 193: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: + case 137: case 183: - case 197: - case 243: - case 242: + case 196: + case 184: + case 174: + case 175: + case 186: + case 200: + case 246: + case 245: return true; - case 189: + case 192: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 191: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 189: + case 190: switch (node.operator) { case 50: case 36: @@ -29211,9 +30218,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 187: + case 181: + case 199: default: return false; } @@ -29233,7 +30240,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 172 || left.kind === 171)) { + if (operator === 57 && (left.kind === 175 || left.kind === 174)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -29390,8 +30397,7 @@ var ts; } function checkAssignmentOperator(valueType) { if (produceDiagnostics && operator >= 57 && operator <= 69) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); - if (ok) { + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } } @@ -29417,7 +30423,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 65536) || isYieldExpressionInClass(node)) { + if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -29491,8 +30497,8 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = skipParenthesizedNodes(node); - return node.kind === 178 || node.kind === 196; + node = ts.skipParentheses(node); + return node.kind === 181 || node.kind === 199; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -29518,14 +30524,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -29548,7 +30554,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -29556,9 +30562,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 173 && node.parent.expression === node) || - (node.parent.kind === 174 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 176 && node.parent.expression === node) || + (node.parent.kind === 177 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); 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); } @@ -29580,66 +30586,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 193: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 171: - return checkArrayLiteral(node, contextualMapper); - case 172: - return checkObjectLiteral(node, contextualMapper); - case 173: - return checkPropertyAccessExpression(node); case 174: - return checkIndexedAccess(node); + return checkArrayLiteral(node, contextualMapper); case 175: + return checkObjectLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkPropertyAccessExpression(node); case 177: - return checkTaggedTemplateExpression(node); - case 179: - return checkExpression(node.expression, contextualMapper); - case 193: - return checkClassExpression(node); - case 180: - case 181: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183: - return checkTypeOfExpression(node); + return checkIndexedAccess(node); case 178: - case 196: - return checkAssertion(node); - case 197: - return checkNonNullAssertion(node); + case 179: + return checkCallExpression(node); + case 180: + return checkTaggedTemplateExpression(node); case 182: - return checkDeleteExpression(node); + return checkExpression(node.expression, contextualMapper); + case 196: + return checkClassExpression(node); + case 183: case 184: - return checkVoidExpression(node); - case 185: - return checkAwaitExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 186: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 181: + case 199: + return checkAssertion(node); + case 200: + return checkNonNullAssertion(node); + case 185: + return checkDeleteExpression(node); case 187: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkAwaitExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkPrefixUnaryExpression(node); + case 190: + return checkPostfixUnaryExpression(node); case 191: + return checkBinaryExpression(node, contextualMapper); + case 192: + return checkConditionalExpression(node, contextualMapper); + case 195: + return checkSpreadExpression(node, contextualMapper); + case 197: + return undefinedWideningType; + case 194: return checkYieldExpression(node); - case 248: + case 251: return checkJsxExpression(node); - case 242: + case 245: return checkJsxElement(node); - case 243: + case 246: return checkJsxSelfClosingElement(node); - case 244: + case 247: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -29660,7 +30666,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -29671,7 +30677,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 149 || func.kind === 153 || func.kind === 158) { + if (func.kind === 150 || func.kind === 154 || func.kind === 159) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -29683,9 +30689,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 148 || - node.kind === 221 || - node.kind === 180; + return node.kind === 149 || + node.kind === 224 || + node.kind === 183; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -29726,9 +30732,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_18 = _a[_i].name; - if (ts.isBindingPattern(name_18) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { + var name_22 = _a[_i].name; + if (ts.isBindingPattern(name_22) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -29741,16 +30747,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 184: + case 153: + case 224: + case 183: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_11 = node.parent; + if (node === parent_11.type) { + return parent_11; } } } @@ -29760,27 +30766,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_19 = element.name; - if (name_19.kind === 70 && - name_19.text === predicateVariableName) { + var name_23 = element.name; + if (name_23.kind === 70 && + name_23.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 169 || - name_19.kind === 168) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { + else if (name_23.kind === 172 || + name_23.kind === 171) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 154) { + if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || - node.kind === 152 || node.kind === 149 || - node.kind === 153) { + else if (node.kind === 158 || node.kind === 224 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -29792,10 +30798,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 153: + case 154: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 152: + case 153: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -29826,7 +30832,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149) { + if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -29840,13 +30846,13 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 150: + case 151: addName(names, member.name, memberName, 1); break; - case 151: + case 152: addName(names, member.name, memberName, 2); break; - case 146: + case 147: addName(names, member.name, memberName, 3); break; } @@ -29872,7 +30878,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 145) { + if (member.kind == 146) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -29894,7 +30900,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 226) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -29909,7 +30915,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 133: + case 134: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -29917,7 +30923,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -29976,12 +30982,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 180 && n.kind !== 221) { + else if (n.kind !== 183 && n.kind !== 224) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -30001,7 +31007,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -30024,18 +31030,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 150) { + if (node.kind === 151) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 150 ? 151 : 150; + var otherKind = node.kind === 151 ? 152 : 151; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -30049,11 +31055,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 150) { + if (node.kind === 151) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 172) { + if (node.parent.kind !== 175) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -30134,14 +31140,17 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 223 && - n.parent.kind !== 222 && - n.parent.kind !== 193 && + if (n.parent.kind !== 226 && + n.parent.kind !== 225 && + n.parent.kind !== 196 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -30218,7 +31227,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 148 || node.kind === 147) && + var reportError = (node.kind === 149 || node.kind === 148) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -30251,11 +31260,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 226 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { + if (node.kind === 224 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -30366,16 +31375,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: - return 2097152; case 226: + return 2097152; + case 229: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: case 225: + case 228: return 2097152 | 1048576; - case 230: + case 233: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -30467,51 +31476,50 @@ var ts; } } } - function checkCorrectPromiseType(returnType, location, diagnostic, typeName) { - if (returnType === unknownType) { - return unknownType; - } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType === emptyGenericType - || globalPromiseType === getTargetType(returnType)) { - return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - error(location, diagnostic, typeName); - return unknownType; - } function checkAsyncFunctionReturnType(node) { + var returnType = getTypeFromTypeNode(node.type); if (languageVersion >= 2) { - var returnType = getTypeFromTypeNode(node.type); - return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - return unknownType; + else { + markTypeNodeAsReferenced(node.type); + if (returnType === unknownType) { + return unknownType; + } + var promiseConstructorName = ts.getEntityNameFromTypeNode(node.type); + if (promiseConstructorName === undefined) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); + return unknownType; + } + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; + if (promiseConstructorType === unknownType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { + return unknownType; + } + var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var collidingSymbol = getSymbol(node.locals, rootName.text, 107455); + if (collidingSymbol) { + error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, rootName.text, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } } - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - return unknownType; - } - var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - var typeName = promiseConstructor - ? symbolToString(promiseConstructor) - : typeToString(promiseType); - return checkCorrectPromiseType(promiseType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); - } - checkReturnTypeAnnotationAsExpression(node); - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, 107455); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseNameOrNamespaceRoot.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -30523,22 +31531,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 225: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 143: + case 144: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 146: + case 147: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 148: - case 150: + case 149: case 151: + case 152: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -30546,29 +31554,15 @@ var ts; } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } - function checkTypeNodeAsExpression(node) { - if (node && node.kind === 156) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 156 ? 793064 : 1920; - var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608) { - var aliasTarget = resolveAlias(rootSymbol); - if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - function checkTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkReturnTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkParameterTypeAnnotationsAsExpressions(node) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); + function markTypeNodeAsReferenced(node) { + var typeName = node && ts.getEntityNameFromTypeNode(node); + var rootName = typeName && getFirstIdentifier(typeName); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + if (rootSymbol + && rootSymbol.flags & 8388608 + && symbolIsValue(rootSymbol) + && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } function checkDecorators(node) { @@ -30583,21 +31577,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 225: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); + for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + markTypeNodeAsReferenced(parameter.type); + } } break; - case 148: - case 150: + case 149: case 151: - checkParameterTypeAnnotationsAsExpressions(node); - checkReturnTypeAnnotationAsExpression(node); + case 152: + for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + markTypeNodeAsReferenced(parameter.type); + } + markTypeNodeAsReferenced(node.type); break; - case 146: - case 143: - checkTypeAnnotationAsExpression(node); + case 147: + case 144: + markTypeNodeAsReferenced(node.type); break; } } @@ -30616,7 +31616,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 141) { + if (node.name && node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -30658,43 +31658,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 256: - case 226: + case 260: + case 229: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 225: + case 196: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 226: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 183: + case 224: + case 184: + case 149: case 151: + case 152: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 147: - case 152: + case 148: case 153: case 154: - case 157: + case 155: case 158: + case 159: checkUnusedTypeParameters(node); break; } @@ -30703,11 +31703,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { + if (node.parent.kind !== 226 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 143) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -30722,16 +31722,16 @@ var ts; } }; for (var key in node.locals) { - _loop_2(key); + _loop_3(key); } } } function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 219 && - (declaration.parent.parent.kind === 208 || - declaration.parent.parent.kind === 209)) { + if (declaration.kind === 222 && + (declaration.parent.parent.kind === 211 || + declaration.parent.parent.kind === 212)) { return; } } @@ -30748,12 +31748,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 || member.kind === 146) { + if (member.kind === 149 || member.kind === 147) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 149) { + else if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -30798,7 +31798,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 203) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -30820,19 +31820,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 146 || - node.kind === 145 || + if (node.kind === 147 || + node.kind === 146 || + node.kind === 149 || node.kind === 148 || - node.kind === 147 || - node.kind === 150 || - node.kind === 151) { + node.kind === 151 || + node.kind === 152) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -30883,11 +31883,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -30895,11 +31895,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { error(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)); } } @@ -30907,7 +31907,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 222 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -30917,25 +31917,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); - var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 223); + var container = varDeclList.parent.kind === 204 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 200 && ts.isFunctionLike(container.parent) || - container.kind === 227 || - container.kind === 226 || - container.kind === 256); + (container.kind === 203 && ts.isFunctionLike(container.parent) || + container.kind === 230 || + container.kind === 229 || + container.kind === 260); if (!namesShareScope) { - var name_20 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); + var name_24 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 143) { + if (ts.getRootDeclaration(node).kind !== 144) { return; } var func = ts.getContainingFunction(node); @@ -30944,7 +31944,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 176) { return visit(n.expression); } else if (n.kind === 70) { @@ -30958,7 +31958,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 143) { + if (symbol.valueDeclaration.kind === 144) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -30967,7 +31967,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 146 && + if (current.parent.kind === 147 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -30989,33 +31989,34 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 170) { - if (node.propertyName && node.propertyName.kind === 141) { + if (node.kind === 173) { + if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_13 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_13); - var name_21 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_13.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); + var parent_12 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_12); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_12.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -31024,7 +32025,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -31042,9 +32043,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 146 && node.kind !== 145) { + if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 219 || node.kind === 170) { + if (node.kind === 222 || node.kind === 173) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -31054,8 +32055,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 143 && right.kind === 219) || - (left.kind === 219 && right.kind === 143)) { + if ((left.kind === 144 && right.kind === 222) || + (left.kind === 222 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -31082,7 +32083,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 172) { + if (node.modifiers && node.parent.kind === 175) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -31101,7 +32102,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 205) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -31118,12 +32119,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 223) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -31141,18 +32142,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); } @@ -31165,7 +32166,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { 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); @@ -31175,14 +32176,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } var rightType = checkNonNullExpression(node.expression); @@ -31348,7 +32349,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); + return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -31370,12 +32371,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 151) { + if (func.kind === 152) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 149) { + else if (func.kind === 150) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -31393,14 +32394,14 @@ var ts; } } } - else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 262144) { + if (node.flags & 524288) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -31417,8 +32418,9 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); + var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 250 && !hasDuplicateDefaultClause) { + if (clause.kind === 253 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -31430,11 +32432,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 252) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); - if (!isTypeEqualityComparableTo(expressionType, caseType)) { - checkTypeComparableTo(caseType, expressionType, caseClause.expression, undefined); + var caseIsLiteral = isLiteralType(caseType); + var comparedExpressionType = expressionType; + if (!caseIsLiteral || !expressionIsLiteral) { + caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType; + comparedExpressionType = getBaseTypeOfLiteralType(expressionType); + } + if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) { + checkTypeComparableTo(caseType, comparedExpressionType, caseClause.expression, undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -31450,7 +32458,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 218 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -31542,7 +32550,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -31593,7 +32601,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 || declaration.kind === 223) { + if (declaration.kind === 225 || declaration.kind === 226) { if (!firstDecl) { firstDecl = declaration; } @@ -31658,7 +32666,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 222) { + baseType_1.symbol.valueDeclaration.kind === 225) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -31732,7 +32740,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 193) { + if (derivedClassDecl.kind === 196) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -31776,7 +32784,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -31814,8 +32822,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { - var prop = properties_5[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen[prop.name]; if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; @@ -31843,7 +32851,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 226); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -31889,7 +32897,7 @@ var ts; error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { - var text = getTextOfPropertyName(member.name); + var text = ts.getTextOfPropertyName(member.name); if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } @@ -31939,7 +32947,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 189: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -31950,7 +32958,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 191: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -31975,11 +32983,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 182: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 177: + case 176: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -31990,7 +32998,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 177) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -32007,7 +33015,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 176) { current = current.expression; } else { @@ -32067,7 +33075,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 228) { return false; } var enumDeclaration = declaration; @@ -32090,8 +33098,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 222 || - (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 225 || + (declaration.kind === 224 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -32150,7 +33158,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 222); + var mergedClass = ts.getDeclarationOfKind(symbol, 225); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -32193,36 +33201,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 204: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 236: - case 237: + case 239: + case 240: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 233: + case 234: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 170: - case 219: - var name_22 = node.name; - if (ts.isBindingPattern(name_22)) { - for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { + case 173: + case 222: + var name_26 = node.name; + if (ts.isBindingPattern(name_26)) { + for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 222: case 225: - case 221: - case 223: - case 226: + case 228: case 224: + case 226: + case 229: + case 227: if (isGlobalAugmentation) { return; } @@ -32240,12 +33248,12 @@ var ts; switch (node.kind) { case 70: return node; - case 140: + case 141: do { node = node.left; } while (node.kind !== 70); return node; - case 173: + case 176: do { node = node.expression; } while (node.kind !== 70); @@ -32258,9 +33266,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 237 ? + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { + error(moduleName, node.kind === 240 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -32281,7 +33289,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 239 ? + var message = node.kind === 242 ? 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)); @@ -32308,7 +33316,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 236) { checkImportBinding(importClause.namedBindings); } else { @@ -32359,8 +33367,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -32373,7 +33381,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; + var isInAppropriateContext = node.parent.kind === 260 || node.parent.kind === 230 || node.parent.kind === 229; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -32396,8 +33404,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 226 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 260 ? node.parent : node.parent.parent; + if (container.kind === 229 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -32464,7 +33472,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 224 && declaration.kind !== 149) || !!declaration.body; } } @@ -32475,118 +33483,121 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 229: + case 225: case 226: - case 222: - case 223: - case 221: + case 224: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 142: - return checkTypeParameter(node); case 143: + return checkTypeParameter(node); + case 144: return checkParameter(node); + case 147: case 146: - case 145: return checkPropertyDeclaration(node); - case 157: case 158: - case 152: + case 159: case 153: - return checkSignatureDeclaration(node); case 154: return checkSignatureDeclaration(node); - case 148: - case 147: - return checkMethodDeclaration(node); - case 149: - return checkConstructorDeclaration(node); - case 150: - case 151: - return checkAccessorDeclaration(node); - case 156: - return checkTypeReferenceNode(node); case 155: + return checkSignatureDeclaration(node); + case 149: + case 148: + return checkMethodDeclaration(node); + case 150: + return checkConstructorDeclaration(node); + case 151: + case 152: + return checkAccessorDeclaration(node); + case 157: + return checkTypeReferenceNode(node); + case 156: return checkTypePredicate(node); - case 159: - return checkTypeQuery(node); case 160: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 161: - return checkArrayType(node); + return checkTypeLiteral(node); case 162: - return checkTupleType(node); + return checkArrayType(node); case 163: + return checkTupleType(node); case 164: - return checkUnionOrIntersectionType(node); case 165: + return checkUnionOrIntersectionType(node); + case 166: + case 168: return checkSourceElement(node.type); - case 221: - return checkFunctionDeclaration(node); - case 200: - case 227: - return checkBlock(node); - case 201: - return checkVariableStatement(node); - case 203: - return checkExpressionStatement(node); - case 204: - return checkIfStatement(node); - case 205: - return checkDoStatement(node); - case 206: - return checkWhileStatement(node); - case 207: - return checkForStatement(node); - case 208: - return checkForInStatement(node); - case 209: - return checkForOfStatement(node); - case 210: - case 211: - return checkBreakOrContinueStatement(node); - case 212: - return checkReturnStatement(node); - case 213: - return checkWithStatement(node); - case 214: - return checkSwitchStatement(node); - case 215: - return checkLabeledStatement(node); - case 216: - return checkThrowStatement(node); - case 217: - return checkTryStatement(node); - case 219: - return checkVariableDeclaration(node); - case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); + case 169: + return checkIndexedAccessType(node); case 224: - return checkTypeAliasDeclaration(node); - case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); - case 231: - return checkImportDeclaration(node); + return checkFunctionDeclaration(node); + case 203: case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 204: + return checkVariableStatement(node); + case 206: + return checkExpressionStatement(node); + case 207: + return checkIfStatement(node); + case 208: + return checkDoStatement(node); + case 209: + return checkWhileStatement(node); + case 210: + return checkForStatement(node); + case 211: + return checkForInStatement(node); + case 212: + return checkForOfStatement(node); + case 213: + case 214: + return checkBreakOrContinueStatement(node); + case 215: + return checkReturnStatement(node); + case 216: + return checkWithStatement(node); + case 217: + return checkSwitchStatement(node); case 218: + return checkLabeledStatement(node); + case 219: + return checkThrowStatement(node); + case 220: + return checkTryStatement(node); + case 222: + return checkVariableDeclaration(node); + case 173: + return checkBindingElement(node); + case 225: + return checkClassDeclaration(node); + case 226: + return checkInterfaceDeclaration(node); + case 227: + return checkTypeAliasDeclaration(node); + case 228: + return checkEnumDeclaration(node); + case 229: + return checkModuleDeclaration(node); + case 234: + return checkImportDeclaration(node); + case 233: + return checkImportEqualsDeclaration(node); + case 240: + return checkExportDeclaration(node); + case 239: + return checkExportAssignment(node); + case 205: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 221: + checkGrammarStatementInAmbientContext(node); + return; + case 243: return checkMissingDeclaration(node); } } @@ -32599,17 +33610,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 180: - case 181: + case 183: + case 184: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 196: checkClassExpressionDeferred(node); break; } @@ -32663,8 +33674,19 @@ var ts; function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { + var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); + var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + if (currentGlobalDiagnostics !== previousGlobalDiagnostics) { + var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics); + return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics); + } + else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) { + return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics); + } + return semanticDiagnostics; } ts.forEach(host.getSourceFiles(), checkSourceFile); return diagnostics.getDiagnostics(); @@ -32681,7 +33703,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 216 && node.parent.statement === node) { return true; } node = node.parent; @@ -32703,28 +33725,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 228: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 196: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 225: + case 226: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 183: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -32763,27 +33785,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: + case 143: case 225: + case 226: + case 227: + case 228: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 140) { + while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 271); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 176) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 198; } function forEachEnclosingClass(node, callback) { var result; @@ -32800,13 +33822,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 140) { + while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230) { + if (nodeOnRightSide.parent.kind === 233) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 239) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -32818,7 +33840,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 176) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -32830,11 +33852,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 239 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 230); + if (entityName.kind !== 176 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 233); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -32843,7 +33865,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 198) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -32865,14 +33887,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 176) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 140) { + else if (entityName.kind === 141) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -32881,19 +33903,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 271) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 249) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 155) { + if (entityName.parent.kind === 156) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 256) { + if (node.kind === 260) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -32909,8 +33931,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 170 && - node.parent.parent.kind === 168 && + else if (node.parent.kind === 173 && + node.parent.parent.kind === 171 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -32921,8 +33943,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 176: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -32935,18 +33957,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 166: + case 167: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 149) { + if (constructorDeclaration && constructorDeclaration.kind === 150) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 231 || node.parent.kind === 237) && + ((node.parent.kind === 234 || node.parent.kind === 240) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -32954,7 +33976,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 177 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -32968,7 +33990,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 257) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -33018,20 +34040,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 172 || expr.kind === 171); - if (expr.parent.kind === 209) { + ts.Debug.assert(expr.kind === 175 || expr.kind === 174); + if (expr.parent.kind === 212) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 191) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 256) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 171); + ts.Debug.assert(expr.parent.kind === 174); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -33067,9 +34089,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_23 = symbol.name; + var name_27 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_23); + var symbol = getPropertyOfType(t, name_27); if (symbol) { symbols_3.push(symbol); } @@ -33077,6 +34099,10 @@ var ts; return symbols_3; } else if (symbol.flags & 67108864) { + if (symbol.leftSpread) { + var links = symbol; + return [links.leftSpread, links.rightSpread]; + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -33134,7 +34160,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 260) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -33172,7 +34198,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 203 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -33212,16 +34238,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: case 233: case 235: - case 239: + case 236: + case 238: + case 242: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237: + case 240: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 239: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -33231,7 +34257,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 256 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 260 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -33282,7 +34308,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 259) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -33376,9 +34402,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_14 = reference.parent; - if (ts.isDeclaration(parent_14) && reference === parent_14.name) { - location = getDeclarationContainer(parent_14); + var parent_13 = reference.parent; + if (ts.isDeclaration(parent_13) && reference === parent_13.name) { + location = getDeclarationContainer(parent_13); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -33398,7 +34424,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 262144); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -33449,13 +34475,14 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - writeLiteralConstValue: writeLiteralConstValue + writeLiteralConstValue: writeLiteralConstValue, + getJsxFactoryEntity: function () { return _jsxFactoryEntity; } }; function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 176) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -33477,6 +34504,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -33487,15 +34517,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_14 = getParentOfSymbol(current); + if (parent_14) { + current = parent_14; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 260 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -33514,7 +34544,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 260); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -33544,7 +34574,7 @@ var ts; } } if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 31744; + var fileRequestedExternalEmitHelpers = file.flags & 64512; if (fileRequestedExternalEmitHelpers) { requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; if (firstFileRequestingExternalHelpers === undefined) { @@ -33613,9 +34643,13 @@ var ts; if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { verifyHelperSymbol(exports, "__extends", 107455); } - if (requestedExternalEmitHelpers & 16384 && compilerOptions.jsx !== 1) { + if (requestedExternalEmitHelpers & 16384 && + (languageVersion < 5 || compilerOptions.jsx === 2)) { verifyHelperSymbol(exports, "__assign", 107455); } + if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { + verifyHelperSymbol(exports, "__rest", 107455); + } if (requestedExternalEmitHelpers & 2048) { verifyHelperSymbol(exports, "__decorate", 107455); if (compilerOptions.emitDecoratorMetadata) { @@ -33662,14 +34696,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 149 && !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 === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { 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); @@ -33686,17 +34720,17 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 129) { - if (node.kind === 145 || node.kind === 147) { + if (modifier.kind !== 130) { + if (node.kind === 146 || node.kind === 148) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 154) { + if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 225 && node.parent.kind === 222) { + if (node.kind !== 228 && node.parent.kind === 225) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -33722,7 +34756,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -33745,10 +34779,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -33757,11 +34791,11 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 129: + case 130: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { + else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -33780,10 +34814,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -33795,13 +34829,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -33811,14 +34845,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 222) { - if (node.kind !== 148 && - node.kind !== 146 && - node.kind !== 150 && - node.kind !== 151) { + if (node.kind !== 225) { + if (node.kind !== 149 && + node.kind !== 147 && + node.kind !== 151 && + node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 225 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -33837,7 +34871,7 @@ var ts; else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -33845,7 +34879,7 @@ var ts; break; } } - if (node.kind === 149) { + if (node.kind === 150) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -33860,13 +34894,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 234 || node.kind === 233) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -33882,37 +34916,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 150: case 151: - case 149: - case 146: - case 145: - case 148: + case 152: + case 150: case 147: - case 154: - case 226: - case 231: - case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 146: + case 149: + case 148: + case 155: + case 229: + case 234: + case 233: + case 240: + case 239: + case 183: + case 184: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 230 || node.parent.kind === 260) { return false; } switch (node.kind) { - case 221: - return nodeHasAnyModifiersExcept(node, 119); - case 222: - return nodeHasAnyModifiersExcept(node, 116); - case 223: - case 201: case 224: - return true; + return nodeHasAnyModifiersExcept(node, 119); case 225: + return nodeHasAnyModifiersExcept(node, 116); + case 226: + case 204: + case 227: + return true; + case 228: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -33925,10 +34959,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 224: + case 183: + case 184: if (!node.asteriskToken) { return false; } @@ -33990,7 +35024,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 184) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -34025,7 +35059,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 !== 133 && parameter.type.kind !== 131) { + if (parameter.type.kind !== 134 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -34052,7 +35086,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 194) { + if (arg.kind === 197) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -34122,19 +35156,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 141) { + if (node.kind !== 142) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 191 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 221 || - node.kind === 180 || - node.kind === 148); + ts.Debug.assert(node.kind === 224 || + node.kind === 183 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -34159,42 +35193,45 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_24 = prop.name; - if (name_24.kind === 141) { - checkGrammarComputedPropertyName(name_24); + if (prop.kind === 258) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_28 = prop.name; + if (name_28.kind === 142) { + checkGrammarComputedPropertyName(name_28); + } + if (prop.kind === 257 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 148) { + if (mod.kind !== 119 || prop.kind !== 149) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 253 || prop.kind === 254) { + if (prop.kind === 256 || prop.kind === 257) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_24.kind === 8) { - checkGrammarNumericLiteral(name_24); + if (name_28.kind === 8) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } - else if (prop.kind === 148) { + else if (prop.kind === 149) { currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = GetAccessor; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -34204,18 +35241,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -34224,19 +35261,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 247) { + if (attr.kind === 250) { continue; } var jsxAttr = attr; - var name_25 = jsxAttr.name; - if (!seen[name_25.text]) { - seen[name_25.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 248 && !initializer.expression) { + if (initializer && initializer.kind === 251 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -34245,7 +35282,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 223) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -34253,20 +35290,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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); @@ -34290,11 +35327,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 150 ? + return grammarErrorOnNode(accessor.name, kind === 151 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 151) { + else if (kind === 152) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -34313,10 +35350,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -34331,7 +35368,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 175) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -34347,10 +35384,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -34361,9 +35398,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 218: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 213 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -34371,8 +35408,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 217: + if (node.kind === 214 && !node.label) { return false; } break; @@ -34385,13 +35422,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 214 ? 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 === 211 + var message = node.kind === 214 ? 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); @@ -34401,9 +35438,9 @@ var ts; if (node.dotDotDotToken) { var elements = node.parent.elements; if (node !== ts.lastOrUndefined(elements)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 169 || node.name.kind === 168) { + if (node.name.kind === 172 || node.name.kind === 171) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -34413,11 +35450,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { + if (node.parent.parent.kind !== 211 && node.parent.parent.kind !== 212) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -34474,15 +35511,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: case 207: case 208: case 209: + case 216: + case 210: + case 211: + case 212: return false; - case 215: + case 218: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -34537,7 +35574,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34545,7 +35582,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -34558,13 +35595,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 223 || - node.kind === 224 || - node.kind === 231 || - node.kind === 230 || - node.kind === 237 || - node.kind === 236 || - node.kind === 229 || + if (node.kind === 226 || + node.kind === 227 || + node.kind === 234 || + node.kind === 233 || + node.kind === 240 || + node.kind === 239 || + node.kind === 232 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -34573,7 +35610,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 === 201) { + if (ts.isDeclaration(decl) || decl.kind === 204) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -34592,7 +35629,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 203 || node.parent.kind === 230 || node.parent.kind === 260) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -34631,49 +35668,49 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[140] = [ + _a[141] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[144] = [ + _a[145] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[178] = [ + _a[181] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[199] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[200] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[228] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[230] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[233] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[244] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[259] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -34686,41 +35723,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return initial; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return initial; } var result = initial; switch (node.kind) { - case 199: case 202: - case 194: - case 218: - case 287: + case 205: + case 197: + case 221: + case 291: break; - case 141: + case 142: result = reduceNode(node.expression, f, result); break; - case 143: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 144: - result = reduceNode(node.expression, f, result); - break; - case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 148: + case 145: + result = reduceNode(node.expression, f, result); + break; + case 147: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 149: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34729,17 +35766,9 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 149: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 150: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 151: @@ -34747,46 +35776,54 @@ var ts; result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 168: - case 169: + case 152: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.body, f, result); + break; + case 171: + case 172: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 173: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 174: result = ts.reduceLeft(node.elements, f, result); break; - case 172: - result = ts.reduceLeft(node.properties, f, result); - break; - case 173: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); - break; - case 174: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); - break; case 175: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.name, f, result); + break; + case 177: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.argumentExpression, f, result); + break; + case 178: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 179: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 180: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 183: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -34794,117 +35831,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 179: case 182: - case 183: - case 184: case 185: - case 191: - case 192: - case 197: - result = reduceNode(node.expression, f, result); - break; case 186: case 187: + case 188: + case 194: + case 195: + case 200: + result = reduceNode(node.expression, f, result); + break; + case 189: + case 190: result = reduceNode(node.operand, f, result); break; - case 188: + case 191: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 192: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 193: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 196: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 195: + case 198: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 201: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 203: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 204: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 206: result = reduceNode(node.expression, f, result); break; - case 204: + case 207: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 208: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 209: + case 216: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 210: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 208: - case 209: + case 211: + case 212: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: - case 216: + case 215: + case 219: result = reduceNode(node.expression, f, result); break; - case 214: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 218: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 220: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 222: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 223: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 224: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34913,7 +35950,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -34921,89 +35958,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 231: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 234: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 232: + case 235: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 236: result = reduceNode(node.name, f, result); break; - case 234: - case 238: + case 237: + case 241: result = ts.reduceLeft(node.elements, f, result); break; - case 235: - case 239: + case 238: + case 242: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 239: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 242: + case 245: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 243: - case 244: + case 246: + case 247: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 248: result = reduceNode(node.tagName, f, result); break; - case 246: + case 249: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247: - result = reduceNode(node.expression, f, result); - break; - case 248: - result = reduceNode(node.expression, f, result); - break; - case 249: - result = reduceNode(node.expression, f, result); case 250: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNode(node.expression, f, result); break; case 251: - result = ts.reduceLeft(node.types, f, result); + result = reduceNode(node.expression, f, result); break; case 252: + result = reduceNode(node.expression, f, result); + case 253: + result = ts.reduceLeft(node.statements, f, result); + break; + case 254: + result = ts.reduceLeft(node.types, f, result); + break; + case 255: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 256: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 258: + result = reduceNode(node.expression, f, result); + break; + case 260: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 292: result = reduceNode(node.expression, f, result); break; default: @@ -35028,6 +36068,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -35070,6 +36111,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; + aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -35106,178 +36148,180 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return node; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return node; } switch (node.kind) { - case 199: case 202: - case 194: - case 218: - return node; - case 141: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 143: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 148: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 151: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 168: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 171: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 177: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 182: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 190: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 195: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 200: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 205: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 210: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 212: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 213: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 219: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 220: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 197: case 221: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return node; + case 142: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 144: + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 147: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 149: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 152: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 171: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 172: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 173: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 174: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 175: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 176: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 177: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 178: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 179: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 182: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 184: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 185: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 189: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 190: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 193: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 194: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 195: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 198: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 203: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 204: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 206: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 207: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 208: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 209: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 212: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 213: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 214: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 216: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 217: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 218: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 219: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 222: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 223: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 224: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 225: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 228: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 231: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 232: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 233: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 236: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 237: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 240: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 241: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); case 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 243: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 248: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 252: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 254: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 255: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 256: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 257: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 258: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 260: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 292: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -35381,7 +36425,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor) { + function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { var right = node.right; if (ts.isDestructuringAssignment(right)) { @@ -35400,7 +36444,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); if (needsValue) { expressions.push(value); } @@ -35418,11 +36462,14 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor, transformRest) { var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -35435,12 +36482,15 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { var declarations = []; var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -35470,33 +36520,39 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { var pendingAssignments = []; - flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, false, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; function emitAssignment(name, value, location, original) { - var left = nameSubstitution && nameSubstitution(name) || name; - emitPendingAssignment(left, value, location, original); + var expression = createAssignmentCallback + ? createAssignmentCallback(name.kind === 70 ? name : emitTempVariableAssignment(name, location), value, location) + : ts.createAssignment(name, value, location); + emitPendingAssignment(expression, original); } function emitTempVariableAssignment(value, location) { var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(name, value, location, undefined); + emitPendingAssignment(ts.createAssignment(name, value, location), undefined); return name; } - function emitPendingAssignment(name, value, location, original) { - var expression = ts.createAssignment(name, value, location); + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectLiteral(elements), value, location, original); + } + function emitPendingAssignment(expression, original) { expression.original = original; ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); - return expression; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -35527,17 +36583,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 175) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 174) { emitArrayLiteralAssignment(target, value, location); } else { - var name_26 = ts.getMutableClone(target); - ts.setSourceMapRange(name_26, target); - ts.setCommentRange(name_26, target); - emitAssignment(name_26, value, location, undefined); + var name_30 = ts.getMutableClone(target); + ts.setSourceMapRange(name_30, target); + ts.setCommentRange(name_30, target); + emitAssignment(name_30, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -35545,16 +36601,78 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); } - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; - if (p.kind === 253 || p.kind === 254) { - var propName = p.name; - var target_1 = p.kind === 254 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createDestructuringPropertyAccess(value, propName), p); + var bindingElements = []; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 256 || p.kind === 257) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 256 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 257 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && p.kind === 258) { + ts.Debug.assert(p.expression.kind === 70); + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.expression; + var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); + emitDestructuringAssignment(propName, restCall, p); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; } } function emitArrayLiteralAssignment(target, value, location) { + if (transformRest) { + emitESNextArrayLiteralAssignment(target, value, location); + } + else { + emitES2015ArrayLiteralAssignment(target, value, location); + } + } + function emitESNextArrayLiteralAssignment(target, value, location) { + var elements = target.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, true, location, emitTempVariableAssignment); + } + var expressions = []; + var spreadContainingExpressions = []; + for (var i = 0; i < numElements; i++) { + var e = elements[i]; + if (e.kind === 197) { + continue; + } + if (e.transformFlags & 8388608 && i < numElements - 1) { + var tmp = ts.createTempVariable(recordTempVariable); + spreadContainingExpressions.push([e, tmp]); + expressions.push(tmp); + } + else { + expressions.push(e); + } + } + emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); + for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { + var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; + emitDestructuringAssignment(e, tmp, e); + } + } + function emitES2015ArrayLiteralAssignment(target, value, location) { var elements = target.elements; var numElements = elements.length; if (numElements !== 1) { @@ -35562,8 +36680,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 194) { - if (e.kind !== 192) { + if (e.kind !== 197) { + if (e.kind !== 195) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -35572,42 +36690,130 @@ var ts; } } } + function createRestCall(value, elements, getPropertyName, location) { + var propertyNames = []; + for (var i = 0; i < elements.length - 1; i++) { + if (ts.isOmittedExpression(elements[i])) { + continue; + } + var str = ts.createSynthesizedNode(9); + str.pos = location.pos; + str.end = location.end; + str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); + propertyNames.push(str); + } + var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.createIdentifier("__rest"), undefined, args); + } function emitBindingElement(target, value) { var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (initializer) { + if (transformRest) { + value = value || initializer; + } + else if (initializer) { value = value ? createDefaultValueCheck(value, initializer, target) : initializer; } else if (!value) { value = ts.createVoidZero(); } var name = target.name; - if (ts.isBindingPattern(name)) { - var elements = name.elements; - var numElements = elements.length; + if (!ts.isBindingPattern(name)) { + emitAssignment(name, value, target, target); + } + else { + var numElements = name.elements.length; if (numElements !== 1) { value = ensureIdentifier(value, numElements !== 0, target, emitTempVariableAssignment); } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - else if (name.kind === 168) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } - else { - if (!element.dotDotDotToken) { - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + if (name.kind === 172) { + emitArrayBindingElement(name, value); + } + else { + emitObjectBindingElement(target, value); } } + } + function emitArrayBindingElement(name, value) { + if (transformRest) { + emitESNextArrayBindingElement(name, value); + } else { - emitAssignment(name, value, target, target); + emitES2015ArrayBindingElement(name, value); + } + } + function emitES2015ArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (!element.dotDotDotToken) { + emitBindingElement(element, ts.createElementAccess(value, i)); + } + else if (i === numElements - 1) { + emitBindingElement(element, ts.createArraySlice(value, i)); + } + } + } + function emitESNextArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + var spreadContainingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (element.transformFlags & 8388608 && i < numElements - 1) { + spreadContainingElements.push(element); + bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + } + else { + bindingElements.push(element); + } + } + emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); + for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { + var element = spreadContainingElements_1[_i]; + emitBindingElement(element, ts.getGeneratedNameForNode(element)); + } + } + function emitObjectBindingElement(target, value) { + var name = target.name; + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (i === numElements - 1 && element.dotDotDotToken) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); + emitBindingElement(element, restCall); + } + else if (transformRest && !(element.transformFlags & 8388608)) { + bindingElements.push(element); + } + else { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var propName = element.propertyName || element.name; + emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; } } function createDefaultValueCheck(value, defaultValue, location) { @@ -35660,14 +36866,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(176); + context.enableSubstitution(177); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -35693,7 +36899,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 260) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -35709,13 +36915,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 234: return visitImportDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); - case 236: + case 239: return visitExportAssignment(node); - case 237: + case 240: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -35725,11 +36931,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 237 || - node.kind === 231 || - node.kind === 232 || - (node.kind === 230 && - node.moduleReference.kind === 241)) { + if (node.kind === 240 || + node.kind === 234 || + node.kind === 235 || + (node.kind === 233 && + node.moduleReference.kind === 244)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -35745,21 +36951,30 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 149: - return undefined; - case 146: - case 154: case 150: + return undefined; + case 147: + case 155: case 151: - case 148: + case 152: + case 149: return visitorWorker(node); - case 199: + case 202: return node; default: ts.Debug.failBadSyntaxKind(node); return undefined; } } + function modifierVisitor(node) { + if (ts.modifierToFlag(node.kind) & 2270) { + return undefined; + } + else if (currentNamespace && node.kind === 83) { + return undefined; + } + return node; + } function visitTypeScript(node) { if (ts.hasModifier(node, 2) && ts.isStatement(node)) { return ts.createNotEmittedStatement(node); @@ -35774,78 +36989,80 @@ var ts; case 116: case 75: case 123: - case 129: - case 161: + case 130: case 162: - case 160: - case 155: - case 142: + case 163: + case 161: + case 156: + case 143: case 118: case 121: - case 133: - case 131: - case 128: - case 104: case 134: - case 158: - case 157: + case 132: + case 129: + case 104: + case 135: case 159: - case 156: - case 163: + case 158: + case 160: + case 157: case 164: case 165: case 166: case 167: - case 154: - case 144: - case 224: - case 146: - case 149: - return visitConstructor(node); - case 223: - return ts.createNotEmittedStatement(node); - case 222: - return visitClassDeclaration(node); - case 193: - return visitClassExpression(node); - case 251: - return visitHeritageClause(node); - case 195: - return visitExpressionWithTypeArguments(node); - case 148: - return visitMethodDeclaration(node); + case 168: + case 169: + case 170: + case 155: + case 145: + case 227: + case 147: case 150: - return visitGetAccessor(node); - case 151: - return visitSetAccessor(node); - case 221: - return visitFunctionDeclaration(node); - case 180: - return visitFunctionExpression(node); - case 181: - return visitArrowFunction(node); - case 143: - return visitParameter(node); - case 179: - return visitParenthesizedExpression(node); - case 178: - case 196: - return visitAssertionExpression(node); - case 175: - return visitCallExpression(node); - case 176: - return visitNewExpression(node); - case 197: - return visitNonNullExpression(node); - case 225: - return visitEnumDeclaration(node); - case 201: - return visitVariableStatement(node); - case 219: - return visitVariableDeclaration(node); + return visitConstructor(node); case 226: + return ts.createNotEmittedStatement(node); + case 225: + return visitClassDeclaration(node); + case 196: + return visitClassExpression(node); + case 254: + return visitHeritageClause(node); + case 198: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 182: + return visitParenthesizedExpression(node); + case 181: + case 199: + return visitAssertionExpression(node); + case 178: + return visitCallExpression(node); + case 179: + return visitNewExpression(node); + case 200: + return visitNonNullExpression(node); + case 228: + return visitEnumDeclaration(node); + case 204: + return visitVariableStatement(node); + case 222: + return visitVariableDeclaration(node); + case 229: return visitModuleDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -35854,15 +37071,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 260: + case 231: + case 230: + case 203: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 225: + case 224: if (ts.hasModifier(node, 2)) { break; } @@ -35872,10 +37089,11 @@ var ts; } function visitSourceFile(node) { currentSourceFile = node; - if (compilerOptions.alwaysStrict) { + if (compilerOptions.alwaysStrict && + !(ts.isExternalModule(node) && (compilerOptions.target >= 2 || compilerOptions.module === ts.ModuleKind.ES2015))) { node = ts.ensureUseStrict(node); } - if (node.flags & 31744 + if (node.flags & 64512 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { startLexicalEnvironment(); @@ -35886,10 +37104,10 @@ var ts; externalHelpersModuleImport.parent = node; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); - currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; + currentExternalHelpersModuleName = externalHelpersModuleName; ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - currentSourceFileExternalHelpersModuleName = undefined; + currentExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } @@ -35916,66 +37134,59 @@ var ts; var staticProperties = getInitializedProperties(node, true); var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); - var classAlias; var name = node.name; if (!name && staticProperties.length > 0) { name = ts.getGeneratedNameForNode(node); } - var statements = []; - if (!isDecoratedClass) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - ts.setOriginalNode(classDeclaration, node); - if (staticProperties.length > 0) { - ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); - } - statements.push(classDeclaration); - } - else { - classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); - } + var classStatement = isDecoratedClass + ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) + : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + var statements = [classStatement]; if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, ts.getLocalName(node)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); - addConstructorDecorationStatement(statements, node, classAlias); + addConstructorDecorationStatement(statements, node); if (isNamespaceExport(node)) { addExportMemberAssignment(statements, node); } else if (isDecoratedClass) { if (isDefaultExternalModuleExport(node)) { - statements.push(ts.createExportAssignment(undefined, undefined, false, getLocalName(node))); + statements.push(ts.createExportDefault(ts.getLocalName(node, false, true))); } else if (isNamedExternalModuleExport(node)) { - statements.push(createExternalModuleExport(name)); + statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true))); } } - return statements; + if (statements.length > 1) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432); + } + return ts.singleOrMany(statements); } - function addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause) { + function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var emitFlags = ts.getEmitFlags(node); + if (hasStaticProperties) { + emitFlags |= 1024; + } + ts.setOriginalNode(classDeclaration, node); + ts.setEmitFlags(classDeclaration, emitFlags); + return classDeclaration; + } + function createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) { var location = ts.moveRangePastDecorators(node); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), location), node); - if (!name) { - name = ts.getGeneratedNameForNode(node); - } - var classAlias; - if (resolver.getNodeCheckFlags(node) & 8388608) { - enableSubstitutionForClassAliases(); - classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - } - var declaredName = getDeclarationName(node, true); - var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) - ]), location); - ts.setCommentRange(transformedClassExpression, node); - statements.push(ts.setOriginalNode(transformedClassExpression, node)); - if (classAlias) { - statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(declaredName, undefined, classAlias) - ]), location), node)); - } - return classAlias; + var classAlias = getClassAliasIfNeeded(node); + var declName = ts.getLocalName(node, false, true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = transformClassMembers(node, hasExtendsClause); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + ts.setOriginalNode(classExpression, node); + var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setOriginalNode(statement, node); + ts.setCommentRange(statement, node); + return statement; } function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); @@ -36008,7 +37219,7 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 524288; + var hasParameterPropertyAssignments = node.transformFlags & 4194304; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); @@ -36050,7 +37261,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -36084,7 +37295,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 146 + return member.kind === 147 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -36157,12 +37368,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 150: case 151: + case 152: return getAllDecoratorsOfAccessors(node, member); - case 148: + case 149: return getAllDecoratorsOfMethod(member); - case 146: + case 147: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -36240,37 +37451,33 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 146 + ? member.kind === 147 ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); ts.setEmitFlags(helper, 49152); return helper; } - function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { - var expression = generateConstructorDecorationExpression(node, decoratedClassAlias); + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); if (expression) { statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); } } - function generateConstructorDecorationExpression(node, decoratedClassAlias) { + function generateConstructorDecorationExpression(node) { var allDecorators = getAllDecoratorsOfConstructor(node); var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators); if (!decoratorExpressions) { return undefined; } - if (decoratedClassAlias) { - var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); - var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } - else { - var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = ts.getLocalName(node, false, true); + var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 49152); + ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); + return expression; } function transformDecorator(decorator) { return ts.visitNode(decorator.expression, visitor, ts.isExpression); @@ -36281,7 +37488,7 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); + var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); ts.setEmitFlags(helper, 49152); expressions.push(helper); } @@ -36299,13 +37506,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -36313,58 +37520,58 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeParameterTypesOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 148 - || kind === 150 + return kind === 149 || kind === 151 - || kind === 146; + || kind === 152 + || kind === 147; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 148; + return node.kind === 149; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 222 - || kind === 193 - || kind === 148 - || kind === 150 - || kind === 151; + return kind === 225 + || kind === 196 + || kind === 149 + || kind === 151 + || kind === 152; } function serializeTypeOfNode(node) { switch (node.kind) { - case 146: - case 143: - case 150: - return serializeTypeNode(node.type); + case 147: + case 144: case 151: + return serializeTypeNode(node.type); + case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 222: - case 193: - case 148: + case 225: + case 196: + case 149: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 161) { + if (node && node.kind === 162) { return node.elementType; } - else if (node && node.kind === 156) { + else if (node && node.kind === 157) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -36412,20 +37619,20 @@ var ts; switch (node.kind) { case 104: return ts.createVoidZero(); - case 165: + case 166: return serializeTypeNode(node.type); - case 157: case 158: + case 159: return ts.createIdentifier("Function"); - case 161: case 162: + case 163: return ts.createIdentifier("Array"); - case 155: + case 156: case 121: return ts.createIdentifier("Boolean"); - case 133: + case 134: return ts.createIdentifier("String"); - case 167: + case 170: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -36439,16 +37646,16 @@ var ts; break; } break; - case 131: + case 132: return ts.createIdentifier("Number"); - case 134: + case 135: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 156: + case 157: return serializeTypeReferenceNode(node); + case 165: case 164: - case 163: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -36472,10 +37679,12 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -36517,15 +37726,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_27 = ts.getMutableClone(node); - name_27.flags &= ~8; - name_27.original = undefined; - name_27.parent = currentScope; + var name_31 = ts.getMutableClone(node); + name_31.flags &= ~8; + name_31.original = undefined; + name_31.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); } - return name_27; - case 140: + return name_31; + case 141: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -36599,7 +37808,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setCommentRange(method, node); ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); @@ -36612,27 +37821,27 @@ var ts; if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitSetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitFunctionDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); if (isNamespaceExport(node)) { var statements = [func]; @@ -36645,12 +37854,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } @@ -36697,7 +37906,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); @@ -36719,7 +37928,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); @@ -36755,39 +37964,32 @@ var ts; || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } - function shouldEmitVarForEnumDeclaration(node) { - return isFirstEmittedDeclarationInScope(node) - && (!ts.hasModifier(node, 1) - || isES6ExportedDeclaration(node)); - } - function addVarForEnumExportedFromNamespace(statements, node) { - var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - ts.setSourceMapRange(statement, node); - statements.push(statement); - } function visitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { return undefined; } var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForEnumDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); + var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); + moduleArg = ts.createAssignment(localName, moduleArg); + } + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); - if (isNamespaceExport(node)) { - addVarForEnumExportedFromNamespace(statements, node); - } + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformEnumBody(node, localName) { @@ -36822,9 +38024,11 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isES6ExportedDeclaration(node) { - return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES2015; + function hasNamespaceQualifiedExportName(node) { + return isNamespaceExport(node) + || (isExternalModuleExport(node) + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -36839,32 +38043,37 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_28 = node.symbol && node.symbol.name; - if (name_28) { - return currentScopeFirstDeclarationsOfName[name_28] === node; + var name_32 = node.symbol && node.symbol.name; + if (name_32) { + return currentScopeFirstDeclarationsOfName[name_32] === node; } } return false; } - function shouldEmitVarForModuleDeclaration(node) { - return isFirstEmittedDeclarationInScope(node); - } function addVarForEnumOrModuleDeclaration(statements, node) { - var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) - ? ts.visitNodes(node.modifiers, visitor, ts.isModifier) - : undefined, [ - ts.createVariableDeclaration(getDeclarationName(node, false, true)) + var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), [ + ts.createVariableDeclaration(ts.getLocalName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 225) { - ts.setSourceMapRange(statement.declarationList, node); + recordEmittedDeclarationInScope(node); + if (isFirstEmittedDeclarationInScope(node)) { + if (node.kind === 228) { + ts.setSourceMapRange(statement.declarationList, node); + } + else { + ts.setSourceMapRange(statement, node); + } + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 | 33554432); + statements.push(statement); + return true; } else { - ts.setSourceMapRange(statement, node); + var mergeMarker = ts.createMergeDeclarationMarker(statement); + ts.setEmitFlags(mergeMarker, 49152 | 33554432); + statements.push(mergeMarker); + return false; } - ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768); - statements.push(statement); } function visitModuleDeclaration(node) { if (!shouldEmitModuleDeclaration(node)) { @@ -36874,25 +38083,26 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForModuleDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); - if (ts.hasModifier(node, 1) && !isES6ExportedDeclaration(node)) { - var localName = getLocalName(node); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformModuleBody(node, namespaceLocalName) { @@ -36907,7 +38117,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 230) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -36930,13 +38140,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 230) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 229) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -36956,7 +38166,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 236) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -37008,8 +38218,8 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ - ts.createVariableDeclaration(node.name, undefined, moduleReference) + return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) ]), node), node); } else { @@ -37034,36 +38244,20 @@ var ts; return ts.createStatement(expression, undefined); } function addExportMemberAssignment(statements, node) { - var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); + var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(getNamespaceMemberName(exportName, false, true), exportValue), location); + return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); } - function createExternalModuleExport(exportName) { - return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ - ts.createExportSpecifier(exportName) - ])); - } - function getNamespaceMemberName(name, allowComments, allowSourceMaps) { - var qualifiedName = ts.createPropertyAccess(currentNamespaceContainerName, ts.getSynthesizedClone(name), name); - var emitFlags; - if (!allowComments) { - emitFlags |= 49152; - } - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (emitFlags) { - ts.setEmitFlags(qualifiedName, emitFlags); - } - return qualifiedName; + function createNamespaceExportExpression(exportName, exportValue, location) { + return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { - return getNamespaceMemberName(name, false, true); + return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); @@ -37073,40 +38267,21 @@ var ts; function getNamespaceContainerName(node) { return ts.getGeneratedNameForNode(node); } - function getLocalName(node, noSourceMaps, allowComments) { - return getDeclarationName(node, allowComments, !noSourceMaps, 262144); - } - function getExportName(node, noSourceMaps, allowComments) { - if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); - } - return getDeclarationName(node, allowComments, !noSourceMaps, 131072); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name) { - var name_29 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_29, emitFlags); - } - return name_29; - } - else { - return ts.getGeneratedNameForNode(node); + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 8388608) { + enableSubstitutionForClassAliases(); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; } } function getClassPrototype(node) { - return ts.createPropertyAccess(getDeclarationName(node), "prototype"); + return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { return ts.hasModifier(member, 32) - ? getDeclarationName(node) + ? ts.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { @@ -37126,15 +38301,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(257); + context.enableEmitNotification(229); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 229; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 228; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -37159,14 +38334,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_30 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_30); + var name_33 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_33); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_30, initializer, node); + return ts.createPropertyAssignment(name_33, initializer, node); } - return ts.createPropertyAssignment(name_30, exportedName, node); + return ts.createPropertyAssignment(name_33, exportedName, node); } } return node; @@ -37175,9 +38350,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); } return node; @@ -37205,11 +38380,11 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 226) || - (applicableSubstitutions & 8 && container.kind === 225); + if (container && container.kind !== 260) { + var substitute = (applicableSubstitutions & 2 && container.kind === 229) || + (applicableSubstitutions & 8 && container.kind === 228); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -37252,1392 +38427,6 @@ var ts; ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); var ts; -(function (ts) { - function transformES2015Module(context) { - var compilerOptions = context.getCompilerOptions(); - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230: - return undefined; - case 236: - return visitExportAssignment(node); - } - return node; - } - function visitExportAssignment(node) { - return node.isExportEquals ? undefined : node; - } - } - ts.transformES2015Module = transformES2015Module; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableEmitNotification(256); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], ~1 & ts.getEmitFlags(node)); - var _a; - } - function addSystemModuleBody(statements, node, dependencyGroups) { - startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - ts.addRange(statements, endLexicalEnvironment()); - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 237 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return addExportStarFunction(statements, undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 237) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 231: - if (!entry.importClause) { - break; - } - case 230: - ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 237: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); - } - else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); - } - return ts.createArrayLiteral(setters, undefined, true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 231: - return visitImportDeclaration(node); - case 230: - return visitImportEqualsDeclaration(node); - case 237: - return visitExportDeclaration(node); - case 236: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 201: - return visitVariableStatement(node); - case 221: - return visitFunctionDeclaration(node); - case 222: - return visitClassDeclaration(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 209: - return visitForOfStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 215: - return visitLabeledStatement(node); - case 213: - return visitWithStatement(node); - case 214: - return visitSwitchStatement(node); - case 228: - return visitCaseBlock(node); - case 249: - return visitCaseClause(node); - case 250: - return visitDefaultClause(node); - case 217: - return visitTryStatement(node); - case 252: - return visitCatchClause(node); - case 200: - return visitBlock(node); - case 203: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - return createExportStatement(ts.createLiteral("default"), node.expression); - } - function visitVariableStatement(node) { - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || - enclosingBlockScopedContainer.kind === 256; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - function transformVariable(node, isExported) { - hoistBindingElement(node, isExported); - if (!node.initializer) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - return ts.createAssignment(name, node.initializer); - } - else { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); - } - } - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1)) { - var name_31 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_31, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { - var name_32 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - function visitClassDeclaration(node) { - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); - if (ts.hasModifier(node, 1)) { - if (!ts.hasModifier(node, 512)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; - } - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); - } - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 188: - return substituteBinaryExpression(node); - case 186: - case 187: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128); - var left = node.left; - switch (left.kind) { - case 70: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 172: - case 171: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 70: - return isExportedBinding(node); - case 172: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 171: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 57 - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 70 - || kind === 172 - || kind === 171; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 187 || - (node.kind === 186 && (operator === 42 || operator === 43))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128); - var call = createExportExpression(operand, expr); - if (node.kind === 186) { - return call; - } - else { - return operator === 42 - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ - ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) - ], undefined, true))); - return exportStarFunction; - } - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); - } - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableSubstitution(254); - context.enableEmitNotification(256); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); - } - return updated; - } - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, true); - } - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16); - return transformAsynchronousModule(node, define, undefined, false); - } - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, true); - var body = ts.createBlock(statements, undefined, true); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(body, 2); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, exportEquals); - ts.setEmitFlags(statement, 12288 | 49152); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); - ts.setEmitFlags(statement, 49152); - statements.push(statement); - } - } - } - function visitor(node) { - switch (node.kind) { - case 231: - return visitImportDeclaration(node); - case 230: - return visitImportEqualsDeclaration(node); - case 237: - return visitExportDeclaration(node); - case 236: - return visitExportAssignment(node); - case 201: - return visitVariableStatement(node); - case 221: - return visitFunctionDeclaration(node); - case 222: - return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - statements.push(ts.createStatement(createRequireCall(node), node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); - } - else { - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - ts.setEmitFlags(node.name, 128); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) - ], undefined, languageVersion >= 2 ? 2 : 0), node)); - } - } - else { - if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) - ]), node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); - } - return ts.singleOrMany(statements); - } - else { - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), node); - } - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512)) { - addExportDefault(statements, getDeclarationName(node), node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); - } - } - function visitVariableStatement(node) { - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 226 || - originalKind === 225 || - originalKind === 222) { - if (!ts.hasModifier(node, 1)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); - } - var resultStatements = []; - if (ts.hasModifier(node, 1)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - var isAsync = ts.hasModifier(node, 256); - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 225 || origKind === 226) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 222) { - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - if (ts.hasModifier(original, 1) && - original.kind === 225 && - ts.isFirstDeclarationOfKind(original, 225)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - ts.setEmitFlags(transformedStatement, 49152); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 188: - return substituteBinaryExpression(node); - case 187: - case 186: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128); - var transformedUnaryExpression = void 0; - if (node.kind === 187) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); - ts.setEmitFlags(transformedUnaryExpression, 128); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); - if (container) { - if (container.kind === 256) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), node); - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); -var ts; (function (ts) { var entities = createEntitiesMap(); function transformJsx(context) { @@ -38666,11 +38455,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 245: return visitJsxElement(node, false); - case 243: + case 246: return visitJsxSelfClosingElement(node, false); - case 248: + case 251: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38681,11 +38470,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 251: return visitJsxExpression(node); - case 242: + case 245: return visitJsxElement(node, true); - case 243: + case 246: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38715,7 +38504,7 @@ var ts; objectProperties = ts.singleOrUndefined(segments) || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -38737,7 +38526,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 251) { return visitJsxExpression(node); } else { @@ -38802,16 +38591,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 245) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_34 = node.tagName; + if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { + return ts.createLiteral(name_34.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_34); } } } @@ -39088,6 +38877,163 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + currentSourceFile = node; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16) { + return visitorWorker(node); + } + else if (node.transformFlags & 32) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 175: + return visitObjectLiteralExpression(node); + case 191: + return visitBinaryExpression(node); + case 222: + return visitVariableDeclaration(node); + case 212: + return visitForOfStatement(node); + case 171: + case 172: + return node; + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 258) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 256) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 175) { + objects.unshift(ts.createObjectLiteral()); + } + return ts.createCall(ts.createIdentifier("__assign"), undefined, objects); + } + function visitBinaryExpression(node) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, visitor, true); + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48) { + var result = ts.flattenVariableDestructuring(node, undefined, visitor, undefined, true); + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitForOfStatement(node) { + var initializer = node.initializer; + if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { + return ts.visitEachChild(node, visitor, context); + } + return ts.convertForOf(node, undefined, visitor, ts.noop, context, true); + } + function isRestBindingPattern(initializer) { + if (ts.isVariableDeclarationList(initializer)) { + var declaration = ts.firstOrUndefined(initializer.declarations); + return declaration && declaration.name && + declaration.name.kind === 171 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 175 && + initializer.transformFlags & 8388608; + } + function visitParameter(node) { + if (isObjectRestParameter(node)) { + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, node.initializer, node), node); + } + else { + return node; + } + } + function isObjectRestParameter(node) { + return node.name && + node.name.kind === 171 && + !!(node.name.transformFlags & 8388608); + } + function visitFunctionDeclaration(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + function visitArrowFunction(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + var func = ts.setOriginalNode(ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, body, node), node); + ts.setEmitFlags(func, 256); + return func; + } + function visitFunctionExpression(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + } + ts.transformESNext = transformESNext; +})(ts || (ts = {})); +var ts; (function (ts) { function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; @@ -39112,10 +39058,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16) { + if (node.transformFlags & 64) { return visitorWorker(node); } - else if (node.transformFlags & 32) { + else if (node.transformFlags & 128) { return ts.visitEachChild(node, visitor, context); } return node; @@ -39124,15 +39070,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 188: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 181: + case 184: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39197,9 +39143,10 @@ var ts; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformAsyncFunctionBody(node) { - var nodeType = node.original ? node.original.type : node.type; + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 181; + var isArrowFunction = node.kind === 184; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -39242,12 +39189,14 @@ var ts; } } function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; + if (type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } } } return undefined; @@ -39255,23 +39204,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(175); - context.enableSubstitution(173); - context.enableSubstitution(174); - context.enableEmitNotification(222); - context.enableEmitNotification(148); - context.enableEmitNotification(150); - context.enableEmitNotification(151); + context.enableSubstitution(178); + context.enableSubstitution(176); + context.enableSubstitution(177); + context.enableEmitNotification(225); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); - case 175: + case 178: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -39314,11 +39263,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 225 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -39364,10 +39313,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 64) { + if (node.transformFlags & 256) { return visitorWorker(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -39376,7 +39325,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 191: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39489,11 +39438,11 @@ var ts; return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression; + return isInConstructorWithCapturedSuper && node.kind === 215 && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 218 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { @@ -39503,7 +39452,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39522,15 +39471,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 215: node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 204: return visitVariableStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 211: - case 210: + case 214: + case 213: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39542,76 +39491,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 225: return visitClassDeclaration(node); - case 193: + case 196: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 181: + case 184: return visitArrowFunction(node); - case 180: + case 183: return visitFunctionExpression(node); - case 219: + case 222: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 223: return visitVariableDeclarationList(node); - case 215: + case 218: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); case 208: - return visitForInStatement(node); + return visitDoStatement(node); case 209: + return visitWhileStatement(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: return visitForOfStatement(node); - case 203: + case 206: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 252: - return visitCatchClause(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 255: + return visitCatchClause(node); + case 257: + return visitShorthandPropertyAssignment(node); + case 174: + return visitArrayLiteralExpression(node); + case 178: return visitCallExpression(node); - case 176: - return visitNewExpression(node); case 179: + return visitNewExpression(node); + case 182: return visitParenthesizedExpression(node, true); - case 188: + case 191: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 180: return visitTaggedTemplateExpression(node); - case 190: + case 193: return visitTemplateExpression(node); - case 191: + case 194: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 194: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 260: return visitSourceFileNode(node); - case 201: + case 204: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39626,7 +39575,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 184) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39634,14 +39583,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 204: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 223: + case 222: + case 173: + case 171: + case 172: break; default: enclosingVariableStatement = undefined; @@ -39669,7 +39618,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 184) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39689,13 +39638,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 214 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 211) { + if (node.kind === 214) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39705,7 +39654,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 214) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39735,26 +39684,26 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitClassDeclaration(node) { - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1; - var isDefault = modifierFlags & 512; - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) - ]), node); + var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); + ts.setOriginalNode(variable, node); + var statements = []; + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); ts.setOriginalNode(statement, node); ts.startOnNewLine(statement); - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); - return statements; + statements.push(statement); + if (ts.hasModifier(node, 1)) { + var exportStatement = ts.hasModifier(node, 512) + ? ts.createExportDefault(ts.getLocalName(node)) + : ts.createExternalModuleExport(ts.getLocalName(node)); + ts.setOriginalNode(exportStatement, statement); + statements.push(exportStatement); } - return statement; - } - function isExportModifier(node) { - return node.kind === 83; + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 33554432) === 0) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statement, emitFlags | 33554432); + } + return ts.singleOrMany(statements); } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39764,7 +39713,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39785,7 +39734,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = getLocalName(node); + var localName = ts.getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 49152); @@ -39800,13 +39749,13 @@ var ts; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 256); } @@ -39829,8 +39778,8 @@ var ts; statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); } if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, false); + ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -39857,17 +39806,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 215) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 207) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 203) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -39878,7 +39827,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -39887,7 +39836,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -39896,7 +39845,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 206 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -39905,7 +39854,7 @@ var ts; statements.push(ts.createReturn(superCallExpression)); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); if (superCallExpression) { return 1; } @@ -39922,111 +39871,33 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); } else { return node; } } - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 262144) !== 0; - } - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); - } - } - } - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); - } - } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); - } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; - } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536); - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 65536 && node.kind !== 181) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 | 8388608); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 199: + case 202: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 148: + case 149: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 149: + case 150: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40091,7 +39962,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -40102,80 +39973,22 @@ var ts; return transformFunctionLikeToExpression(node, node, node.name); } function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), node), node); } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181) { + if (node.kind !== 184) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } - function transformFunctionBody(node) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 181); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); - ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 179: + case 182: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 191: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -40183,9 +39996,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 182: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 191: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -40231,7 +40044,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 + if (node.transformFlags & 67108864 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -40250,8 +40063,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 211 + && enclosingBlockScopeContainer.kind !== 212 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -40313,68 +40126,7 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(undefined); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); - ts.setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement(undefined, declarationList)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); - } - } - else { - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); - } - else { - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } - ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - ts.setEmitFlags(body, 1536 | 12288); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - ts.setEmitFlags(forStatement, 8192); - return forStatement; + return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, false); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -40382,8 +40134,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 141) { + if (property.transformFlags & 134217728 + || property.name.kind === 142) { numInitialProperties = i; break; } @@ -40438,11 +40190,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 210: + case 211: + case 212: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 223) { loopInitializer = initializer; } break; @@ -40481,7 +40233,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 16777216) !== 0; + && (node.statement.transformFlags & 134217728) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -40489,9 +40241,9 @@ var ts; if (isAsyncBlockContainingAwait) { loopBodyFlags |= 2097152; } - var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ])); + ]), 16777216)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -40549,7 +40301,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 218 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40648,7 +40400,7 @@ var ts; } } else { - loopParameters.push(ts.createParameter(name)); + loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { var outParamName = ts.createUniqueName("out_" + name.text); loopOutParameters.push({ originalName: name, outParamName: outParamName }); @@ -40661,20 +40413,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; - case 253: + case 256: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 257: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40744,7 +40496,7 @@ var ts; ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 1048576) { + if (node.transformFlags & 8388608) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { @@ -40761,35 +40513,35 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 1048576) !== 0); + ts.Debug.assert((node.transformFlags & 8388608) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 174 ? ts.createArraySlice(segments[0]) : segments[0]; } return ts.createArrayConcat(segments.shift(), segments); } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function partitionSpread(node) { + return ts.isSpreadExpression(node) + ? visitSpanOfSpreads + : visitSpanOfNonSpreads; } - function visitSpanOfSpreadElements(chunk) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function visitSpanOfSpreads(chunk) { + return ts.map(chunk, visitExpressionOfSpread); } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); } - function visitExpressionOfSpreadElement(node) { + function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { @@ -40862,7 +40614,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 178 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -40871,7 +40623,7 @@ var ts; var statements = []; startLexicalEnvironment(); ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); + ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); ts.addRange(statements, endLexicalEnvironment()); var clone = ts.getMutableClone(node); @@ -40896,13 +40648,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(149); - context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(149); context.enableEmitNotification(151); - context.enableEmitNotification(181); - context.enableEmitNotification(180); - context.enableEmitNotification(221); + context.enableEmitNotification(152); + context.enableEmitNotification(184); + context.enableEmitNotification(183); + context.enableEmitNotification(224); } } function onSubstituteNode(emitContext, node) { @@ -40927,10 +40679,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: + case 173: case 225: - case 219: + case 228: + case 222: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -40962,28 +40714,8 @@ var ts; } return node; } - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_38 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_38, emitFlags); - } - return name_38; - } - return ts.getGeneratedNameForNode(node); - } function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); + var expression = ts.getLocalName(node); return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { @@ -40995,11 +40727,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 206) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 178) { return false; } var callTarget = statementExpression.expression; @@ -41007,7 +40739,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 195) { return false; } var expression = callArgument.expression; @@ -41063,7 +40795,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 4096) { + if (node.transformFlags & 8192) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -41078,10 +40810,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 2048) { + else if (transformFlags & 4096) { return visitGenerator(node); } - else if (transformFlags & 4096) { + else if (transformFlags & 8192) { return ts.visitEachChild(node, visitor, context); } else { @@ -41090,13 +40822,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 208: return visitDoStatement(node); - case 206: + case 209: return visitWhileStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 215: + case 218: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41104,30 +40836,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 204: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 211: - return visitBreakStatement(node); case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 214: + return visitBreakStatement(node); + case 213: return visitContinueStatement(node); - case 212: + case 215: return visitReturnStatement(node); default: - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (4096 | 33554432)) { + else if (node.transformFlags & (8192 | 268435456)) { return ts.visitEachChild(node, visitor, context); } else { @@ -41137,21 +40869,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: - return visitBinaryExpression(node); - case 189: - return visitConditionalExpression(node); case 191: + return visitBinaryExpression(node); + case 192: + return visitConditionalExpression(node); + case 194: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); case 174: - return visitElementAccessExpression(node); + return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 177: + return visitElementAccessExpression(node); + case 178: return visitCallExpression(node); - case 176: + case 179: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41159,9 +40891,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -41264,7 +40996,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -41318,10 +41050,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 176: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 177: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41513,35 +41245,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200: - return transformAndEmitBlock(node); case 203: - return transformAndEmitExpressionStatement(node); - case 204: - return transformAndEmitIfStatement(node); - case 205: - return transformAndEmitDoStatement(node); + return transformAndEmitBlock(node); case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitExpressionStatement(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitIfStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitDoStatement(node); + case 209: + return transformAndEmitWhileStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitForStatement(node); case 211: - return transformAndEmitBreakStatement(node); - case 212: - return transformAndEmitReturnStatement(node); + return transformAndEmitForInStatement(node); case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitContinueStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitBreakStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitReturnStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitWithStatement(node); case 217: + return transformAndEmitSwitchStatement(node); + case 218: + return transformAndEmitLabeledStatement(node); + case 219: + return transformAndEmitThrowStatement(node); + case 220: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41825,7 +41557,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 250 && defaultClauseIndex === -1) { + if (clause.kind === 253 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41835,7 +41567,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 249) { + if (clause.kind === 252) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -41926,7 +41658,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216) !== 0; + return node && (node.transformFlags & 134217728) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -41956,9 +41688,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_8 = ts.getMutableClone(name_39); + var name_35 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_35) { + var clone_8 = ts.getMutableClone(name_35); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -42257,7 +41989,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -42266,7 +41998,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -42354,7 +42086,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -42625,8 +42357,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(176); + context.enableSubstitution(256); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42666,6 +42398,1462 @@ var ts; ts.transformES5 = transformES5; })(ts || (ts = {})); var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 233: + return undefined; + case 239: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); + var exportFunctionsMap = ts.createMap(); + var noSubstitutionMap = ts.createMap(); + var currentSourceFile; + var moduleInfo; + var exportFunction; + var contextObject; + var hoistedStatements; + var enclosingBlockScopedContainer; + var noSubstitution; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + enclosingBlockScopedContainer = node; + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + contextObject = ts.createUniqueName("context"); + var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, exportFunction), + ts.createParameter(undefined, undefined, undefined, contextObject) + ], undefined, createSystemModuleBody(node, dependencyGroups)); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction])) + ], node.statements)); + ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1); + if (noSubstitution) { + noSubstitutionMap[id] = noSubstitution; + noSubstitution = undefined; + } + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + contextObject = undefined; + hoistedStatements = undefined; + enclosingBlockScopedContainer = undefined; + return ts.aggregateTransformFlags(updated); + } + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + function createSystemModuleBody(node, dependencyGroups) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) + ]))); + var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + ts.addRange(statements, hoistedStatements); + ts.addRange(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ]), true))); + var body = ts.createBlock(statements, undefined, true); + ts.setEmitFlags(body, 1); + return body; + } + function addExportStarIfNeeded(statements) { + if (!moduleInfo.hasExportStarsToExportValues) { + return; + } + if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { + var externalImport = _a[_i]; + if (externalImport.kind === 240 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + var exportStarFunction_1 = createExportStarFunction(undefined); + statements.push(exportStarFunction_1); + return exportStarFunction_1.name; + } + } + var exportedNames = []; + if (moduleInfo.exportedNames) { + for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) { + var exportedLocalName = _c[_b]; + if (exportedLocalName.text === "default") { + continue; + } + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + } + } + for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { + var externalImport = _e[_d]; + if (externalImport.kind !== 240) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { + var element = _g[_f]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ]))); + var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); + statements.push(exportStarFunction); + return exportStarFunction.name; + } + function createExportStarFunction(localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + } + return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([ + ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ])), + ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) + ], undefined, true)); + } + function createSettersArray(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 234: + if (!entry.importClause) { + break; + } + case 233: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 240: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + } + else { + statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + } + return ts.createArrayLiteral(setters, undefined, true); + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 234: + return visitImportDeclaration(node); + case 233: + return visitImportEqualsDeclaration(node); + case 240: + return undefined; + case 239: + return visitExportAssignment(node); + default: + return nestedElementVisitor(node); + } + } + function visitImportDeclaration(node) { + var statements; + if (node.importClause) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var expression = ts.visitNode(node.expression, destructuringVisitor, ts.isExpression); + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true); + } + else { + return createExportStatement(ts.createIdentifier("default"), expression, true); + } + } + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1)) { + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + } + else { + hoistedStatements = ts.append(hoistedStatements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); + } + return undefined; + } + function visitClassDeclaration(node) { + var statements; + var name = ts.getLocalName(node); + hoistVariableDeclaration(name); + statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + if (!shouldHoistVariableDeclarationList(node.declarationList)) { + return ts.visitNode(node, destructuringVisitor, ts.isStatement); + } + var expressions; + var isExportedDeclaration = ts.hasModifier(node, 1); + var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } + var statements; + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + if (isMarkedDeclaration) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + } + else { + statements = appendExportsOfVariableStatement(statements, node, false); + } + return ts.singleOrMany(statements); + } + function hoistBindingElement(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + hoistBindingElement(element); + } + } + } + else { + hoistVariableDeclaration(ts.getSynthesizedClone(node.name)); + } + } + function shouldHoistVariableDeclarationList(node) { + return (ts.getEmitFlags(node) & 16777216) === 0 + && (enclosingBlockScopedContainer.kind === 260 + || (ts.getOriginalNode(node).flags & 3) === 0); + } + function transformInitializedVariable(node, isExportedDeclaration) { + var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; + return ts.isBindingPattern(node.name) + ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); + } + function createExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, true); + } + function createNonExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, false); + } + function createVariableAssignment(name, value, location, isExportedDeclaration) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + return isExportedDeclaration + ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) + : preventSubstitution(ts.createAssignment(name, value, location)); + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + var isExportedDeclaration = ts.hasModifier(node.original, 1); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.initializer || exportSelf) { + statements = appendExportsOfBindingElement(statements, decl, exportSelf); + } + } + return statements; + } + function appendExportsOfBindingElement(statements, decl, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element, exportSelf); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + var excludeName = void 0; + if (exportSelf) { + statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl)); + excludeName = decl.name.text; + } + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var excludeName; + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl)); + excludeName = exportName.text; + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl, excludeName) { + if (moduleInfo.exportEquals) { + return statements; + } + var name = ts.getDeclarationName(decl); + var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + if (exportSpecifier.name.text !== excludeName) { + statements = appendExportStatement(statements, exportSpecifier.name, name); + } + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, allowComments)); + return statements; + } + function createExportStatement(name, value, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value)); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; + return ts.createCall(exportFunction, undefined, [exportName, value]); + } + function nestedElementVisitor(node) { + switch (node.kind) { + case 204: + return visitVariableStatement(node); + case 224: + return visitFunctionDeclaration(node); + case 225: + return visitClassDeclaration(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: + return visitForOfStatement(node); + case 208: + return visitDoStatement(node); + case 209: + return visitWhileStatement(node); + case 218: + return visitLabeledStatement(node); + case 216: + return visitWithStatement(node); + case 217: + return visitSwitchStatement(node); + case 231: + return visitCaseBlock(node); + case 252: + return visitCaseClause(node); + case 253: + return visitDefaultClause(node); + case 220: + return visitTryStatement(node); + case 255: + return visitCatchClause(node); + case 203: + return visitBlock(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); + default: + return destructuringVisitor(node); + } + } + function visitForStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForInStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForOfStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function shouldHoistForInitializer(node) { + return ts.isVariableDeclarationList(node) + && shouldHoistVariableDeclarationList(node); + } + function visitForInitializer(node) { + if (shouldHoistForInitializer(node)) { + var expressions = void 0; + for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + expressions = ts.append(expressions, transformInitializedVariable(variable, false)); + } + return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression(); + } + else { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + } + function visitDoStatement(node) { + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + } + function visitWhileStatement(node) { + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitLabeledStatement(node) { + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitWithStatement(node) { + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitSwitchStatement(node) { + return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + } + function visitCaseBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitCaseClause(node) { + return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + } + function visitDefaultClause(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitTryStatement(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitCatchClause(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.visitEachChild(node, nestedElementVisitor, context); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function destructuringVisitor(node) { + if (node.transformFlags & 16384 + && node.kind === 191) { + return visitDestructuringAssignment(node); + } + else if (node.transformFlags & 32768) { + return ts.visitEachChild(node, destructuringVisitor, context); + } + else { + return node; + } + } + function visitDestructuringAssignment(node) { + if (hasExportedReferenceInDestructuringTarget(node.left)) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, destructuringVisitor); + } + return ts.visitEachChild(node, destructuringVisitor, context); + } + function hasExportedReferenceInDestructuringTarget(node) { + if (ts.isAssignmentExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.left); + } + else if (ts.isSpreadExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.expression); + } + else if (ts.isObjectLiteralExpression(node)) { + return ts.some(node.properties, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isArrayLiteralExpression(node)) { + return ts.some(node.elements, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.initializer); + } + else if (ts.isIdentifier(node)) { + var container = resolver.getReferencedExportContainer(node); + return container !== undefined && container.kind === 260; + } + else { + return false; + } + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260) { + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; + if (noSubstitution) { + delete noSubstitutionMap[id]; + } + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (isSubstitutionPrevented(node)) { + return node; + } + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 191: + return substituteBinaryExpression(node); + case 189: + case 190: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + } + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createPrefix(node.operator, node.operand, node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 190) { + expression = node.operator === 42 + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); + } + return expression; + } + } + return node; + } + function getExports(name) { + var exportedNames; + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + var exportContainer = resolver.getReferencedExportContainer(name, false); + if (exportContainer && exportContainer.kind === 260) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); + } + } + return exportedNames; + } + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = ts.createMap(); + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70); + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableSubstitution(257); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); + var currentSourceFile; + var currentModuleInfo; + var noSubstitution; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, false); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); + } + return updated; + } + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, true); + } + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16); + return transformAsynchronousModule(node, define, undefined, false); + } + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") + ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) + ]))) + ], node.statements)); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 128); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, true); + var body = ts.createBlock(statements, undefined, true); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.setEmitFlags(body, 2); + } + return body; + } + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 12288 | 49152); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 49152); + statements.push(statement); + } + } + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 234: + return visitImportDeclaration(node); + case 233: + return visitImportEqualsDeclaration(node); + case 240: + return visitExportDeclaration(node); + case 239: + return visitExportAssignment(node); + case 204: + return visitVariableStatement(node); + case 224: + return visitFunctionDeclaration(node); + case 225: + return visitClassDeclaration(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); + default: + return node; + } + } + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + return ts.createStatement(createRequireCall(node), node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, createRequireCall(node))); + } + else { + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) + ], undefined, languageVersion >= 2 ? 2 : 0))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); + } + else { + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) + ], undefined, languageVersion >= 2 ? 2 : 0), node)); + } + } + else { + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, undefined, createRequireCall(node)) + ]), node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); + } + return ts.singleOrMany(statements); + } + else { + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), node); + } + } + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); + } + return ts.singleOrMany(statements); + } + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1)) { + var modifiers = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + } + else { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + } + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments) { + if (exportName.text === "default") { + var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); + if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 0) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createExportStatement(name, value, location, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value, location) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = ts.createMap(); + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (emitContext === 1) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; + } + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, node); + } + return ts.createPropertyAssignment(name, exportedOrImportedName, node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 191: + return substituteBinaryExpression(node); + case 190: + case 189: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 260) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name_36 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_36), node); + } + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, node); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + : node; + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); +var ts; (function (ts) { var moduleTransformerMap = ts.createMap((_a = {}, _a[ts.ModuleKind.ES2015] = ts.transformES2015Module, @@ -42681,10 +43869,12 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; transformers.push(ts.transformTypeScript); - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (jsx === 2) { transformers.push(ts.transformJsx); } + if (languageVersion < 5) { + transformers.push(ts.transformESNext); + } if (languageVersion < 4) { transformers.push(ts.transformES2017); } @@ -42695,6 +43885,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -42704,7 +43895,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(295); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -42991,7 +44182,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -43004,7 +44195,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -43148,7 +44339,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 291; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -43162,7 +44353,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 223) { declarationListContainerEnd = end; } } @@ -43434,7 +44625,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 231); + ts.Debug.assert(aliasEmitInfo.node.kind === 234); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -43505,10 +44696,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 222) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 237 || declaration.kind === 238 || declaration.kind === 235) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -43519,7 +44710,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 231) { + if (moduleElementEmitInfo.node.kind === 234) { moduleElementEmitInfo.isVisible = true; } else { @@ -43527,12 +44718,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -43645,43 +44836,47 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 166: + case 129: case 167: + case 170: return writeTextOfNode(currentText, type); - case 195: + case 198: return emitExpressionWithTypeArguments(type); - case 156: - return emitTypeReference(type); - case 159: - return emitTypeQuery(type); - case 161: - return emitArrayType(type); - case 162: - return emitTupleType(type); - case 163: - return emitUnionType(type); - case 164: - return emitIntersectionType(type); - case 165: - return emitParenType(type); case 157: - case 158: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 160: + return emitTypeQuery(type); + case 162: + return emitArrayType(type); + case 163: + return emitTupleType(type); + case 164: + return emitUnionType(type); + case 165: + return emitIntersectionType(type); + case 166: + return emitParenType(type); + case 168: + return emitTypeOperator(type); + case 169: + return emitPropertyAccessType(type); + case 158: + case 159: + return emitSignatureDeclarationWithJsDocComments(type); + case 161: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 140: + case 141: return emitEntityName(type); - case 155: + case 156: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -43689,22 +44884,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 140 ? entityName.left : entityName.expression; - var right = entityName.kind === 140 ? entityName.right : entityName.name; + var left = entityName.kind === 141 ? entityName.left : entityName.expression; + var right = entityName.kind === 141 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 233 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 176); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -43750,6 +44945,17 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitPropertyAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -43778,9 +44984,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_37 = baseName + "_" + count; + if (!(name_37 in currentIdentifiers)) { + return name_37; } } } @@ -43824,10 +45030,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 233 || + (node.parent.kind === 260 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 260) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -43836,7 +45042,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 234) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -43854,30 +45060,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221: - return writeFunctionDeclaration(node); - case 201: - return writeVariableStatement(node); - case 223: - return writeInterfaceDeclaration(node); - case 222: - return writeClassDeclaration(node); case 224: - return writeTypeAliasDeclaration(node); - case 225: - return writeEnumDeclaration(node); + return writeFunctionDeclaration(node); + case 204: + return writeVariableStatement(node); case 226: + return writeInterfaceDeclaration(node); + case 225: + return writeClassDeclaration(node); + case 227: + return writeTypeAliasDeclaration(node); + case 228: + return writeEnumDeclaration(node); + case 229: return writeModuleDeclaration(node); - case 230: + case 233: return writeImportEqualsDeclaration(node); - case 231: + case 234: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 260) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -43885,7 +45091,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 226 && !noDeclare) { write("declare "); } } @@ -43935,7 +45141,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 236) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -43958,7 +45164,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 236) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -43975,13 +45181,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 229; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 233) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 229) { moduleSpecifier = parent.name; } else { @@ -44049,7 +45255,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 230) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -44119,7 +45325,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -44129,15 +45335,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - (node.parent.parent && node.parent.parent.kind === 160)) { - ts.Debug.assert(node.parent.kind === 148 || - node.parent.kind === 147 || - node.parent.kind === 157 || + if (node.parent.kind === 158 || + node.parent.kind === 159 || + (node.parent.parent && node.parent.parent.kind === 161)) { + ts.Debug.assert(node.parent.kind === 149 || + node.parent.kind === 148 || node.parent.kind === 158 || - node.parent.kind === 152 || - node.parent.kind === 153); + node.parent.kind === 159 || + node.parent.kind === 153 || + node.parent.kind === 154); emitType(node.constraint); } else { @@ -44147,31 +45353,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { 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 === 222) { + else if (node.parent.parent.kind === 225) { 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 221: + case 224: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -44208,7 +45414,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 225) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -44288,17 +45494,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 222 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 146 || node.kind === 145 || - (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 147 || node.kind === 146 || + (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { + if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -44311,14 +45517,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 146 || node.kind === 145) { + else if (node.kind === 147 || node.kind === 146) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44326,7 +45532,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 === 222) { + else if (node.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44352,7 +45558,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 194) { + if (element.kind !== 197) { elements.push(element); } } @@ -44418,7 +45624,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -44431,7 +45637,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 150 + return accessor.kind === 151 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -44440,7 +45646,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 151) { + if (accessorWithTypeAnnotation.kind === 152) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -44486,17 +45692,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 224) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 148 || node.kind === 149) { + else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 221) { + if (node.kind === 224) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -44516,15 +45722,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 154) { + if (node.kind === 155) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 153 || node.kind === 158) { + if (node.kind === 154 || node.kind === 159) { write("new "); } - else if (node.kind === 157) { + else if (node.kind === 158) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -44535,20 +45741,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 154) { + if (node.kind === 155) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; - if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { + var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; + if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -44562,23 +45768,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 153: + case 154: 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 152: + case 153: 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 154: + case 155: 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 149: case 148: - case 147: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44586,7 +45792,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 === 222) { + else if (node.parent.kind === 225) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -44599,7 +45805,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 224: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -44631,9 +45837,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - node.parent.parent.kind === 160) { + if (node.parent.kind === 158 || + node.parent.kind === 159 || + node.parent.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -44649,22 +45855,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 149: + case 150: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 153: + case 154: 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 152: + case 153: 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 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -44672,7 +45878,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 === 222) { + else if (node.parent.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44684,7 +45890,7 @@ 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 221: + case 224: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -44695,12 +45901,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -44711,10 +45917,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 197) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 173) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -44736,39 +45942,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: case 224: + case 229: + case 233: + case 226: case 225: + case 227: + case 228: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 204: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 234: return emitModuleElement(node, !node.importClause); - case 237: + case 240: return emitExportDeclaration(node); + case 150: case 149: case 148: - case 147: return writeFunctionDeclaration(node); - case 153: - case 152: case 154: + case 153: + case 155: return emitSignatureDeclarationWithJsDocComments(node); - case 150: case 151: + case 152: return emitAccessorDeclaration(node); + case 147: case 146: - case 145: return emitPropertyDeclaration(node); - case 255: + case 259: return emitEnumMemberDeclaration(node); - case 236: + case 239: return emitExportAssignment(node); - case 256: + case 260: return emitSourceFile(node); } } @@ -44830,6 +46036,7 @@ var ts; var brackets = createBracketsMap(); var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; + var restHelper = "\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))\n t[p] = s[p];\n return t;\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -44862,6 +46069,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -44995,7 +46203,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 260: return emitSourceFile(node); } } @@ -45033,7 +46241,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -45047,182 +46254,189 @@ var ts; case 137: case 138: case 139: + case 140: writeTokenText(kind); return; - case 140: - return emitQualifiedName(node); case 141: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 142: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 143: - return emitParameter(node); + return emitTypeParameter(node); case 144: - return emitDecorator(node); + return emitParameter(node); case 145: - return emitPropertySignature(node); + return emitDecorator(node); case 146: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 147: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 148: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 149: - return emitConstructor(node); + return emitMethodDeclaration(node); case 150: + return emitConstructor(node); case 151: - return emitAccessorDeclaration(node); case 152: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 153: - return emitConstructSignature(node); + return emitCallSignature(node); case 154: - return emitIndexSignature(node); + return emitConstructSignature(node); case 155: - return emitTypePredicate(node); + return emitIndexSignature(node); case 156: - return emitTypeReference(node); + return emitTypePredicate(node); case 157: - return emitFunctionType(node); + return emitTypeReference(node); case 158: - return emitConstructorType(node); + return emitFunctionType(node); case 159: - return emitTypeQuery(node); + return emitConstructorType(node); case 160: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 161: - return emitArrayType(node); + return emitTypeLiteral(node); case 162: - return emitTupleType(node); + return emitArrayType(node); case 163: - return emitUnionType(node); + return emitTupleType(node); case 164: - return emitIntersectionType(node); + return emitUnionType(node); case 165: - return emitParenthesizedType(node); - case 195: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 166: - return emitThisType(); - case 167: - return emitLiteralType(node); - case 168: - return emitObjectBindingPattern(node); - case 169: - return emitArrayBindingPattern(node); - case 170: - return emitBindingElement(node); + return emitParenthesizedType(node); case 198: - return emitTemplateSpan(node); - case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitPropertyAccessType(node); + case 170: + return emitLiteralType(node); + case 171: + return emitObjectBindingPattern(node); + case 172: + return emitArrayBindingPattern(node); + case 173: + return emitBindingElement(node); case 201: - return emitVariableStatement(node); + return emitTemplateSpan(node); case 202: - return emitEmptyStatement(); + return emitSemicolonClassElement(); case 203: - return emitExpressionStatement(node); + return emitBlock(node); case 204: - return emitIfStatement(node); + return emitVariableStatement(node); case 205: - return emitDoStatement(node); + return emitEmptyStatement(); case 206: - return emitWhileStatement(node); + return emitExpressionStatement(node); case 207: - return emitForStatement(node); + return emitIfStatement(node); case 208: - return emitForInStatement(node); + return emitDoStatement(node); case 209: - return emitForOfStatement(node); + return emitWhileStatement(node); case 210: - return emitContinueStatement(node); + return emitForStatement(node); case 211: - return emitBreakStatement(node); + return emitForInStatement(node); case 212: - return emitReturnStatement(node); + return emitForOfStatement(node); case 213: - return emitWithStatement(node); + return emitContinueStatement(node); case 214: - return emitSwitchStatement(node); + return emitBreakStatement(node); case 215: - return emitLabeledStatement(node); + return emitReturnStatement(node); case 216: - return emitThrowStatement(node); + return emitWithStatement(node); case 217: - return emitTryStatement(node); + return emitSwitchStatement(node); case 218: - return emitDebuggerStatement(node); + return emitLabeledStatement(node); case 219: - return emitVariableDeclaration(node); + return emitThrowStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitTryStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitDebuggerStatement(node); case 222: - return emitClassDeclaration(node); + return emitVariableDeclaration(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclarationList(node); case 224: - return emitTypeAliasDeclaration(node); + return emitFunctionDeclaration(node); case 225: - return emitEnumDeclaration(node); + return emitClassDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitInterfaceDeclaration(node); case 227: - return emitModuleBlock(node); + return emitTypeAliasDeclaration(node); case 228: - return emitCaseBlock(node); + return emitEnumDeclaration(node); + case 229: + return emitModuleDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleBlock(node); case 231: - return emitImportDeclaration(node); - case 232: - return emitImportClause(node); + return emitCaseBlock(node); case 233: - return emitNamespaceImport(node); + return emitImportEqualsDeclaration(node); case 234: - return emitNamedImports(node); + return emitImportDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportClause(node); case 236: - return emitExportAssignment(node); + return emitNamespaceImport(node); case 237: - return emitExportDeclaration(node); + return emitNamedImports(node); case 238: - return emitNamedExports(node); + return emitImportSpecifier(node); case 239: - return emitExportSpecifier(node); + return emitExportAssignment(node); case 240: - return; + return emitExportDeclaration(node); case 241: + return emitNamedExports(node); + case 242: + return emitExportSpecifier(node); + case 243: + return; + case 244: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 244: - return emitJsxOpeningElement(node); - case 245: - return emitJsxClosingElement(node); - case 246: - return emitJsxAttribute(node); case 247: - return emitJsxSpreadAttribute(node); + return emitJsxOpeningElement(node); case 248: - return emitJsxExpression(node); + return emitJsxClosingElement(node); case 249: - return emitCaseClause(node); + return emitJsxAttribute(node); case 250: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxExpression(node); case 252: - return emitCatchClause(node); + return emitCaseClause(node); case 253: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 255: + return emitCatchClause(node); + case 256: + return emitPropertyAssignment(node); + case 257: + return emitShorthandPropertyAssignment(node); + case 258: + return emitSpreadAssignment(node); + case 259: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -45247,63 +46461,63 @@ var ts; case 98: writeTokenText(kind); return; - case 171: - return emitArrayLiteralExpression(node); - case 172: - return emitObjectLiteralExpression(node); - case 173: - return emitPropertyAccessExpression(node); case 174: - return emitElementAccessExpression(node); + return emitArrayLiteralExpression(node); case 175: - return emitCallExpression(node); + return emitObjectLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitPropertyAccessExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitElementAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitCallExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitNewExpression(node); case 180: - return emitFunctionExpression(node); + return emitTaggedTemplateExpression(node); case 181: - return emitArrowFunction(node); + return emitTypeAssertionExpression(node); case 182: - return emitDeleteExpression(node); + return emitParenthesizedExpression(node); case 183: - return emitTypeOfExpression(node); + return emitFunctionExpression(node); case 184: - return emitVoidExpression(node); + return emitArrowFunction(node); case 185: - return emitAwaitExpression(node); + return emitDeleteExpression(node); case 186: - return emitPrefixUnaryExpression(node); + return emitTypeOfExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitVoidExpression(node); case 188: - return emitBinaryExpression(node); + return emitAwaitExpression(node); case 189: - return emitConditionalExpression(node); + return emitPrefixUnaryExpression(node); case 190: - return emitTemplateExpression(node); + return emitPostfixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitBinaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitConditionalExpression(node); case 193: - return emitClassExpression(node); + return emitTemplateExpression(node); case 194: - return; + return emitYieldExpression(node); + case 195: + return emitSpreadExpression(node); case 196: - return emitAsExpression(node); + return emitClassExpression(node); case 197: + return; + case 199: + return emitAsExpression(node); + case 200: return emitNonNullExpression(node); - case 242: + case 245: return emitJsxElement(node); - case 243: + case 246: return emitJsxSelfClosingElement(node); - case 288: + case 292: return emitPartiallyEmittedExpression(node); } } @@ -45407,7 +46621,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 150 ? "get " : "set "); + write(node.kind === 151 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -45492,6 +46706,17 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitPropertyAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -45655,7 +46880,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 189 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -45699,7 +46924,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -45767,7 +46992,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 207) { write(" "); emit(node.elseStatement); } @@ -45829,7 +47054,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 223) { emit(node); } else { @@ -46058,7 +47283,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 229) { write("."); emit(body.name); body = body.body; @@ -46277,6 +47502,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } function emitEnumMember(node) { emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); @@ -46346,10 +47577,17 @@ var ts; extendsEmitted = true; helpersEmitted = true; } - if (compilerOptions.jsx !== 1 && !assignEmitted && (node.flags & 16384)) { + if ((languageVersion < 5 || currentSourceFile.scriptKind === 2 || currentSourceFile.scriptKind === 4) && + compilerOptions.jsx !== 1 && + !assignEmitted && + node.flags & 16384) { writeLines(assignHelper); assignEmitted = true; } + if (languageVersion < 5 && !restEmitted && node.flags & 32768) { + writeLines(restHelper); + restEmitted = true; + } if (!decorateEmitted && node.flags & 2048) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -46672,7 +47910,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 182 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -46729,21 +47967,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_38 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_38)) { tempFlags |= flags; - return name_41; + return name_38; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_39 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_39)) { + return name_39; } } } @@ -46781,17 +48019,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 229: + case 228: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 234: + case 240: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 224: + case 225: + case 239: return generateNameForExportDefault(); - case 193: + case 196: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -46864,7 +48102,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.2"; + ts.version = "2.1.3"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -47079,11 +48317,11 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_43 = names_2[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_40 = names_1[_i]; + var result = name_40 in cache + ? cache[name_40] + : cache[name_40] = loader(name_40, containingFile); resolutions.push(result); } return resolutions; @@ -47097,7 +48335,7 @@ var ts; var classifiableNames; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; var currentNodeModulesDepth = 0; var modulesWithElidedImports = ts.createMap(); var sourceFilesFoundSearchingNodeModules = ts.createMap(); @@ -47110,7 +48348,14 @@ var ts; var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); var resolveModuleNamesWorker; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { + if (!resolved || resolved.extension !== undefined) { + return resolved; + } + var withExtension = ts.clone(resolved); + withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); + return withExtension; + }); }; } else { var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; @@ -47172,6 +48417,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -47203,6 +48449,79 @@ var ts; } return classifiableNames; } + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + if (!oldProgramState && !file.ambientModuleNames.length) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var unknownModuleNames; + var result; + var predictedToResolveToAmbientModuleMarker = {}; + for (var i = 0; i < moduleNames.length; i++) { + var moduleName = moduleNames[i]; + var isKnownToResolveToAmbientModule = false; + if (ts.contains(file.ambientModuleNames, moduleName)) { + isKnownToResolveToAmbientModule = 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); + } + } + else { + isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + } + if (isKnownToResolveToAmbientModule) { + if (!unknownModuleNames) { + result = new Array(moduleNames.length); + unknownModuleNames = moduleNames.slice(0, i); + } + result[i] = predictedToResolveToAmbientModuleMarker; + } + else if (unknownModuleNames) { + unknownModuleNames.push(moduleName); + } + } + if (!unknownModuleNames) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var resolutions = unknownModuleNames.length + ? resolveModuleNamesWorker(unknownModuleNames, containingFile) + : emptyArray; + var j = 0; + for (var i = 0; i < result.length; i++) { + if (result[i] == predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } + else { + result[i] = resolutions[j]; + j++; + } + } + ts.Debug.assert(j === resolutions.length); + return result; + function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { + if (!oldProgramState) { + return false; + } + var resolutionToFile = ts.getResolvedModule(oldProgramState.file, moduleName); + if (resolutionToFile) { + return false; + } + var ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + if (!(ambientModule && ambientModule.declarations)) { + return false; + } + var firstUnmodifiedFile = ts.forEach(ambientModule.declarations, function (d) { + var f = ts.getSourceFileOfNode(d); + return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && f; + }); + if (!firstUnmodifiedFile) { + return false; + } + if (ts.isTraceEnabled(options, host)) { + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + } + return true; + } + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return false; @@ -47249,40 +48568,44 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { return false; } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else { newSourceFile = oldSourceFile; } newSourceFiles.push(newSourceFile); } + var modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths: modifiedFilePaths }); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } for (var i = 0, len = newSourceFiles.length; i < len; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + for (var _d = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _d < modifiedSourceFiles_2.length; _d++) { + var modifiedFile = modifiedSourceFiles_2[_d]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); oldProgram.structureIsReused = true; @@ -47298,11 +48621,14 @@ var ts; getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, }; } + function isSourceFileFromExternalLibrary(file) { + return sourceFilesFoundSearchingNodeModules[file.path]; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -47379,6 +48705,12 @@ var ts; } } function getSyntacticDiagnosticsForFile(sourceFile) { + if (ts.isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); + } return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -47398,175 +48730,163 @@ var ts; var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; + var parent = sourceFile; walk(sourceFile); return diagnostics; function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 230: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 236: - if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 222: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251: - var heritageClause = node; - if (heritageClause.token === 107) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 223: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 226: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 224: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 148: + switch (parent.kind) { + case 144: case 147: + if (parent.questionToken === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return; + } case 149: + case 148: case 150: case 151: - case 180: - case 221: + case 152: + case 183: + case 224: + case 184: + case 224: + case 222: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 233: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 239: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 254: + var heritageClause = node; + if (heritageClause.token === 107) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 226: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; case 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + var typeAssertionExpression = node; + diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return; + } + var prevParent = parent; + parent = node; + ts.forEachChild(node, walk, walkArray); + parent = prevParent; + } + function walkArray(nodes) { + if (parent.decorators === nodes && !options.experimentalDecorators) { + 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_to_remove_this_warning)); + } + switch (parent.kind) { + case 225: + case 149: + case 148: + case 150: + case 151: + case 152: + case 183: + case 224: + case 184: + case 224: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 204: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 204); } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 175: - case 176: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 143: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 146: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + case 147: + if (nodes === parent.modifiers) { + for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 114) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } - } - if (checkTypeAnnotation(node.type)) { - return true; + return; } break; - case 225: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 178: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; case 144: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + if (nodes === parent.modifiers) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return; } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 113: - case 111: - case 112: - case 129: - case 123: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - case 114: - case 83: - case 75: - case 78: - case 116: + break; + case 178: + case 179: + case 198: + if (nodes === parent.typeArguments) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return; } + break; + } + for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { + var node = nodes_4[_b]; + walk(node); + } + } + function checkModifiers(modifiers, isConstValid) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 75: + if (isConstValid) { + continue; + } + case 113: + case 111: + case 112: + case 130: + case 123: + case 116: + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + break; + case 114: + case 83: + case 78: } } - return false; + } + function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) { + var start = nodes.pos; + return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2); + } + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } }); } @@ -47590,9 +48910,6 @@ var ts; ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } @@ -47611,14 +48928,18 @@ var ts; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); var isExternalModuleFile = ts.isExternalModule(file); + var isDtsFile = ts.isDeclarationFile(file); var imports; var moduleAugmentations; + var ambientModules; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9); + var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; + var importDecl = ts.createSynthesizedNode(234); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -47630,12 +48951,13 @@ var ts; } file.imports = imports || emptyArray; file.moduleAugmentations = moduleAugmentations || emptyArray; + file.ambientModuleNames = ambientModules || emptyArray; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 231: - case 230: - case 237: + case 234: + case 233: + case 240: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -47647,13 +48969,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 229: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { + if (isDtsFile) { + (ambientModules || (ambientModules = [])).push(moduleName.text); + } var body = node.body; if (body) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { @@ -47677,7 +49002,7 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; - if (hasExtension(fileName)) { + if (ts.hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; @@ -47738,7 +49063,7 @@ var ts; processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + if (currentNodeModulesDepth < maxNodeModuleJsDepth) { modulesWithElidedImports[file_1.path] = false; processImportedModules(file_1); } @@ -47847,23 +49172,31 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); + var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); + if (!resolution) { + continue; + } + var isFromNodeModulesSearch = resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; + var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); + var pos = ts.skipTrivia(file.text, file.imports[i].pos); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -47873,7 +49206,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -48027,7 +49359,15 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + if (options.jsxFactory) { + if (options.reactNamespace) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory")); + } + if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory)); + } + } + else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } if (!options.noEmit && !options.suppressOutputPathCheck) { @@ -48042,17 +49382,12 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) { - blockEmittingOfFile(emitFileName); - } - else { - var chain_1; - if (!options.configFilePath) { - chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); - } - chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); - blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); + var chain_1; + if (!options.configFilePath) { + chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); } + chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); } if (emitFilesSeen.contains(emitFilePath)) { blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); @@ -48065,12 +49400,31 @@ var ts; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - if (diag) { - programDiagnostics.add(diag); - } + programDiagnostics.add(diag); } } ts.createProgram = createProgram; + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: + return undefined; + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); + } + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; + } + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + } + } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; (function (ts) { @@ -48144,6 +49498,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -48331,6 +49690,7 @@ var ts; "es2015": 2, "es2016": 3, "es2017": 4, + "esnext": 5, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -48487,7 +49847,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -48754,9 +50115,9 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { - switch (name_44) { + for (var name_41 in options) { + if (ts.hasProperty(options, name_41)) { + switch (name_41) { case "init": case "watch": case "version": @@ -48764,12 +50125,12 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name_41]; + var optionDefinition = optionsNameMap[name_41.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_44] = value; + result[name_41] = value; } else { if (optionDefinition.type === "list") { @@ -48778,10 +50139,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name_41] = convertedValue; } else { - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_41] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -48974,9 +50335,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -49107,14 +50466,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_45 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_45)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_45); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_45) ? 1 : 0; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -49135,6 +50493,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); @@ -49659,17 +51030,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_46 = _a.name, value = _a.value; - if (name_46.length > nameSize) { - nameSize = name_46.length; + var _a = statistics_1[_i], name_42 = _a.name, value = _a.value; + if (name_42.length > nameSize) { + nameSize = name_42.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_47 = _c.name, value = _c.value; - ts.sys.write(padRight(name_47 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name_43 = _c.name, value = _c.value; + ts.sys.write(padRight(name_43 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 0db1007d65b..d701dce92ee 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -26,12 +26,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -44,19 +45,19 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; + })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var ModuleResolutionKind; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; + })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -64,8 +65,16 @@ var ts; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; + })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -204,6 +213,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; function every(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -463,20 +479,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -552,6 +573,26 @@ var ts; return result || array; } ts.compact = compact; + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1: break inner; + case 0: continue outer; + case 1: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -561,15 +602,23 @@ var ts; return result; } ts.sum = sum; + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -588,6 +637,12 @@ var ts; : undefined; } ts.firstOrUndefined = firstOrUndefined; + function lastOrUndefined(array) { + return array && array.length > 0 + ? array[array.length - 1] + : undefined; + } + ts.lastOrUndefined = lastOrUndefined; function singleOrUndefined(array) { return array && array.length === 1 ? array[0] @@ -600,23 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; - } - ts.lastOrUndefined = lastOrUndefined; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; return result; } ts.replaceElement = replaceElement; - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -1374,6 +1423,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -1401,68 +1454,83 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + if (component.charCodeAt(0) === 42) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -1529,25 +1597,30 @@ var ts; for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) { var include = includes_1[_i]; var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); } - basePaths.push(includeBasePath); + }; + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { return (scriptKind || getScriptKindFromFileName(fileName)) || 3; } @@ -1647,10 +1720,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -1796,6 +1865,30 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2090,6 +2183,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -2099,7 +2193,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -2107,7 +2201,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -2122,7 +2216,7 @@ var ts; watchDirectory: function (directoryName, callback, recursive) { var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -2319,7 +2413,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -2546,14 +2640,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -2593,7 +2687,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -2631,8 +2725,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2644,7 +2736,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2666,9 +2758,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -2715,6 +2805,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2738,6 +2835,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -2769,6 +2867,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2868,6 +2969,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -2951,7 +3053,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -2988,11 +3090,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3001,7 +3108,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -3058,6 +3166,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); var ts; @@ -3090,7 +3199,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3100,34 +3209,35 @@ var ts; "instanceof": 92, "interface": 108, "is": 125, + "keyof": 126, "let": 109, - "module": 126, - "namespace": 127, - "never": 128, + "module": 127, + "namespace": 128, + "never": 129, "new": 93, "null": 94, - "number": 131, + "number": 132, "package": 110, "private": 111, "protected": 112, "public": 113, - "readonly": 129, - "require": 130, - "global": 138, + "readonly": 130, + "require": 131, + "global": 139, "return": 95, - "set": 132, + "set": 133, "static": 114, - "string": 133, + "string": 134, "super": 96, "switch": 97, - "symbol": 134, + "symbol": 135, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 135, + "type": 136, "typeof": 102, - "undefined": 136, + "undefined": 137, "var": 103, "void": 104, "while": 105, @@ -3135,7 +3245,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -4522,9 +4632,9 @@ var ts; pos++; return token = 22; } - if (isIdentifierStart(ch, 4)) { + if (isIdentifierStart(ch, 5)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } return token = 70; @@ -4683,6 +4793,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -4870,6 +4985,7 @@ var ts; "es2015": 2, "es2016": 3, "es2017": 4, + "esnext": 5, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -5026,7 +5142,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -5513,9 +5630,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -5646,14 +5761,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_6); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -5674,6 +5788,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); @@ -5742,7 +5869,7 @@ var ts; mergeTypings(typingOptions.include); exclude = typingOptions.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { + if (projectRootPath) { possibleSearchDirs.push(projectRootPath); } searchDirs = ts.deduplicate(possibleSearchDirs); @@ -5765,9 +5892,9 @@ var ts; } } } - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + for (var name_6 in packageNameToTypingLocation) { + if (name_6 in inferredTypings && !inferredTypings[name_6]) { + inferredTypings[name_6] = packageNameToTypingLocation[name_6]; } } for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { @@ -5897,13 +6024,13 @@ var ts; (function (ts) { var server; (function (server) { + var LogLevel; (function (LogLevel) { LogLevel[LogLevel["terse"] = 0] = "terse"; LogLevel[LogLevel["normal"] = 1] = "normal"; LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var LogLevel = server.LogLevel; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); server.emptyArray = []; var Msg; (function (Msg) { @@ -5925,7 +6052,7 @@ var ts; function createInstallTypingsRequest(project, typingOptions, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(), + fileNames: project.getFileNames(true), compilerOptions: project.getCompilerOptions(), typingOptions: typingOptions, unresolvedImports: unresolvedImports, @@ -6147,24 +6274,50 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2: + case 0: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -6173,18 +6326,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -6195,7 +6336,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -6234,7 +6374,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -6261,18 +6400,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -6284,15 +6422,12 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -6308,9 +6443,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -6323,8 +6456,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -6379,15 +6512,15 @@ var ts; return result; } ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -6421,7 +6554,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -6438,7 +6571,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -6449,7 +6582,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -6476,9 +6609,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -6488,53 +6621,63 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0) || tryResolve(1); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -6544,19 +6687,28 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { var directory = ts.getDirectoryPath(candidate); if (directory) { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { @@ -6580,18 +6732,21 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -6601,85 +6756,76 @@ var ts; } failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(0, moduleName, directory, failedLookupLocations, state, false, true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); + var resolved = tryResolve(0) || tryResolve(1); + return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -6690,6 +6836,18 @@ var ts; containingDirectory = parentPath; } } + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0, moduleName, globalCache, failedLookupLocations, state, true) || + loadModuleFromNodeModules(1, moduleName, globalCache, failedLookupLocations, state, true); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); var ts; (function (ts) { @@ -6764,7 +6922,9 @@ var ts; } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -6790,21 +6950,21 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 2097152) !== 0; + return (node.flags & 4194304) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || + if (!(node.flags & 8388608)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; + node.flags |= 4194304; } - node.flags |= 4194304; + node.flags |= 8388608; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { + while (node && node.kind !== 260) { node = node.parent; } return node; @@ -6812,11 +6972,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: return true; } return false; @@ -6881,18 +7041,18 @@ var ts; if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { return getTokenPosOfNode(node.jsDocComments[0]); } - if (node.kind === 286 && node._children.length > 0) { + if (node.kind === 290 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 257 && node.kind <= 282; + return node.kind >= 261 && node.kind <= 286; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + return node.kind >= 277 && node.kind <= 289; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6986,11 +7146,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 219 && node.parent.kind === 252; + return node.kind === 222 && node.parent.kind === 255; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 && + return node && node.kind === 229 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6999,11 +7159,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); + return node.kind === 229 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || + return node.kind === 260 || + node.kind === 229 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7016,9 +7176,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256: + case 260: return ts.isExternalModule(node.parent); - case 227: + case 230: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7026,22 +7186,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { - case 256: - case 228: - case 252: - case 226: - case 207: - case 208: - case 209: - case 149: - case 148: + case 260: + case 231: + case 255: + case 229: + case 210: + case 211: + case 212: case 150: + case 149: case 151: - case 221: - case 180: - case 181: + case 152: + case 224: + case 183: + case 184: return true; - case 200: + case 203: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7061,12 +7221,42 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70: + return name.text; + case 9: + case 8: + return name.text; + case 142: + if (isStringOrNumericLiteral(name.expression.kind)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70: + return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); + case 141: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 176: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { var span = getErrorSpanForNode(sourceFile, node); return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } - ts.createDiagnosticForNode = createDiagnosticForNode; + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -7089,7 +7279,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200) { + if (node.body && node.body.kind === 203) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7101,29 +7291,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256: + case 260: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 219: - case 170: case 222: - case 193: - case 223: - case 226: + case 173: case 225: - case 255: - case 221: - case 180: - case 148: - case 150: - case 151: + case 196: + case 226: + case 229: + case 228: + case 259: case 224: + case 183: + case 149: + case 151: + case 152: + case 227: errorNode = node.name; break; - case 181: + case 184: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7144,7 +7334,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); + return node.kind === 228 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7157,11 +7347,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; + return n.kind === 178 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; + return node.kind === 206 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -7177,10 +7367,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 || - node.kind === 142 || - node.kind === 180 || - node.kind === 181) ? + var commentRanges = (node.kind === 144 || + node.kind === 143 || + node.kind === 183 || + node.kind === 184) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -7195,69 +7385,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (155 <= node.kind && node.kind <= 167) { + if (156 <= node.kind && node.kind <= 170) { return true; } switch (node.kind) { case 118: - case 131: - case 133: - case 121: + case 132: case 134: - case 136: - case 128: + case 121: + case 135: + case 137: + case 129: return true; case 104: - return node.parent.kind !== 184; - case 195: + return node.parent.kind !== 187; + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 140 && node.parent.right === node) { + if (node.parent.kind === 141 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 173 && node.parent.name === node) { + else if (node.parent.kind === 176 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 140: - case 173: + ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 176, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 176: case 98: var parent_2 = node.parent; - if (parent_2.kind === 159) { + if (parent_2.kind === 160) { return false; } - if (155 <= parent_2.kind && parent_2.kind <= 167) { + if (156 <= parent_2.kind && parent_2.kind <= 170) { return true; } switch (parent_2.kind) { - case 195: + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 142: - return node === parent_2.constraint; - case 146: - case 145: case 143: - case 219: + return node === parent_2.constraint; + case 147: + case 146: + case 144: + case 222: return node === parent_2.type; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: + case 150: case 149: case 148: - case 147: - case 150: case 151: - return node === parent_2.type; case 152: + return node === parent_2.type; case 153: case 154: + case 155: + return node === parent_2.type; + case 181: return node === parent_2.type; case 178: - return node === parent_2.type; - case 175: - case 176: + case 179: return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 177: + case 180: return false; } } @@ -7268,23 +7458,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212: + case 215: return visitor(node); - case 228: - case 200: - case 204: - case 205: - case 206: + case 231: + case 203: case 207: case 208: case 209: - case 213: - case 214: - case 249: - case 250: - case 215: + case 210: + case 211: + case 212: + case 216: case 217: case 252: + case 253: + case 218: + case 220: + case 255: return ts.forEachChild(node, traverse); } } @@ -7294,24 +7484,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 194: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225: - case 223: + case 228: case 226: - case 224: - case 222: - case 193: + case 229: + case 227: + case 225: + case 196: return; default: if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 141) { - traverse(name_8.expression); + var name_7 = node.name; + if (name_7 && name_7.kind === 142) { + traverse(name_7.expression); return; } } @@ -7325,14 +7515,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170: - case 255: - case 143: - case 253: + case 173: + case 259: + case 144: + case 256: + case 147: case 146: - case 145: - case 254: - case 219: + case 257: + case 222: return true; } } @@ -7340,11 +7530,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 150 || node.kind === 151); + return node && (node.kind === 151 || node.kind === 152); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 222 || node.kind === 193); + return node && (node.kind === 225 || node.kind === 196); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7353,19 +7543,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 149: - case 180: - case 221: - case 181: - case 148: - case 147: case 150: + case 183: + case 224: + case 184: + case 149: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return true; } return false; @@ -7373,13 +7563,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 180: + case 152: + case 224: + case 183: return true; } return false; @@ -7387,30 +7577,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207: + case 210: + case 211: + case 212: case 208: case 209: - case 205: - case 206: return true; - case 215: + case 218: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 200 && isFunctionLike(node.parent); + return node && node.kind === 203 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 148 && node.parent.kind === 172; + return node && node.kind === 149 && node.parent.kind === 175; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 && - (node.parent.kind === 172 || - node.parent.kind === 193); + return node.kind === 149 && + (node.parent.kind === 175 || + node.parent.kind === 196); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7446,39 +7636,39 @@ var ts; return undefined; } switch (node.kind) { - case 141: + case 142: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 181: + case 184: if (!includeArrowFunctions) { continue; } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: + case 224: + case 183: + case 229: case 147: + case 146: case 149: + case 148: case 150: case 151: case 152: case 153: case 154: - case 225: - case 256: + case 155: + case 228: + case 260: return node; } } @@ -7491,25 +7681,25 @@ var ts; return node; } switch (node.kind) { - case 141: + case 142: node = node.parent; break; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: if (!stopOnFunctions) { continue; } - case 146: - case 145: - case 148: case 147: + case 146: case 149: + case 148: case 150: case 151: + case 152: return node; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7521,14 +7711,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { + if (func.kind === 183 || func.kind === 184) { var prev = func; var parent_3 = func.parent; - while (parent_3.kind === 179) { + while (parent_3.kind === 182) { prev = parent_3; parent_3 = parent_3.parent; } - if (parent_3.kind === 175 && parent_3.expression === prev) { + if (parent_3.kind === 178 && parent_3.expression === prev) { return parent_3; } } @@ -7536,32 +7726,32 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 || kind === 174) + return (kind === 176 || kind === 177) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 156: - return node.typeName; - case 195: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 70: - case 140: - return node; - } + switch (node.kind) { + case 157: + case 271: + return node.typeName; + case 198: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70: + case 141: + return node; } return undefined; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 175: - case 176: - case 177: - case 144: + case 178: + case 179: + case 180: + case 145: return true; default: return false; @@ -7569,7 +7759,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177) { + if (node.kind === 180) { return node.tag; } return node.expression; @@ -7577,21 +7767,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222: + case 225: return true; - case 146: - return node.parent.kind === 222; - case 150: + case 147: + return node.parent.kind === 225; case 151: - case 148: + case 152: + case 149: return node.body !== undefined - && node.parent.kind === 222; - case 143: + && node.parent.kind === 225; + case 144: return node.parent.body !== undefined - && (node.parent.kind === 149 - || node.parent.kind === 148 - || node.parent.kind === 151) - && node.parent.parent.kind === 222; + && (node.parent.kind === 150 + || node.parent.kind === 149 + || node.parent.kind === 152) + && node.parent.parent.kind === 225; } return false; } @@ -7607,19 +7797,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222: + case 225: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148: - case 151: + case 149: + case 152: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 244 || - parent.kind === 243 || - parent.kind === 245) { + if (parent.kind === 247 || + parent.kind === 246 || + parent.kind === 248) { return parent.tagName === node; } return false; @@ -7633,43 +7823,43 @@ var ts; case 100: case 85: case 11: - case 171: - case 172: - case 173: case 174: case 175: case 176: case 177: - case 196: case 178: - case 197: case 179: case 180: - case 193: + case 199: case 181: - case 184: + case 200: case 182: case 183: - case 186: + case 196: + case 184: case 187: - case 188: - case 189: - case 192: - case 190: - case 12: - case 194: - case 242: - case 243: - case 191: case 185: + case 186: + case 189: + case 190: + case 191: + case 192: + case 195: + case 193: + case 12: + case 197: + case 245: + case 246: + case 194: + case 188: return true; - case 140: - while (node.parent.kind === 140) { + case 141: + while (node.parent.kind === 141) { node = node.parent; } - return node.parent.kind === 159 || isJSXTagName(node); + return node.parent.kind === 160 || isJSXTagName(node); case 70: - if (node.parent.kind === 159 || isJSXTagName(node)) { + if (node.parent.kind === 160 || isJSXTagName(node)) { return true; } case 8: @@ -7677,47 +7867,47 @@ var ts; case 98: var parent_4 = node.parent; switch (parent_4.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 255: - case 253: - case 170: + case 259: + case 256: + case 173: return parent_4.initializer === node; - case 203: - case 204: - case 205: case 206: - case 212: - case 213: - case 214: - case 249: - case 216: - case 214: - return parent_4.expression === node; case 207: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || - forStatement.condition === node || - forStatement.incrementor === node; case 208: case 209: + case 215: + case 216: + case 217: + case 252: + case 219: + case 217: + return parent_4.expression === node; + case 210: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 223) || + forStatement.condition === node || + forStatement.incrementor === node; + case 211: + case 212: var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 223) || forInStatement.expression === node; - case 178: - case 196: + case 181: + case 199: return node === parent_4.expression; - case 198: + case 201: return node === parent_4.expression; - case 141: + case 142: return node === parent_4.expression; - case 144: - case 248: - case 247: + case 145: + case 251: + case 250: return true; - case 195: + case 198: return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: if (isPartOfExpression(parent_4)) { @@ -7735,7 +7925,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; + return node.kind === 233 && node.moduleReference.kind === 244; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7744,7 +7934,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; + return node.kind === 233 && node.moduleReference.kind !== 244; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7752,11 +7942,11 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); + return node && !!(node.flags & 2097152); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 175 && + var isRequire = expression.kind === 178 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7768,9 +7958,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + if (s.valueDeclaration && s.valueDeclaration.kind === 222) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; + return declaration.initializer && declaration.initializer.kind === 183; } return false; } @@ -7779,11 +7969,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 188) { + if (expression.kind !== 191) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 176) { return 0; } var lhs = expr.left; @@ -7799,7 +7989,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 173) { + else if (lhs.expression.kind === 176) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -7815,35 +8005,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231) { + if (node.kind === 234) { return node.moduleSpecifier; } - if (node.kind === 230) { + if (node.kind === 233) { var reference = node.moduleReference; - if (reference.kind === 241) { + if (reference.kind === 244) { return reference.expression; } } - if (node.kind === 237) { + if (node.kind === 240) { return node.moduleSpecifier; } - if (node.kind === 226 && node.name.kind === 9) { + if (node.kind === 229 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 236) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 + return node.kind === 234 && node.importClause && !!node.importClause.name; } @@ -7851,13 +8041,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143: + case 144: + case 149: case 148: + case 257: + case 256: case 147: - case 254: - case 253: case 146: - case 145: return node.questionToken !== undefined; } } @@ -7865,9 +8055,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 && + return node.kind === 273 && node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + node.parameters[0].type.kind === 275; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7918,32 +8108,32 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 201; + node.parent.parent.parent.kind === 204; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; + node.parent.parent.kind === 204; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 226 && - node.parent && node.parent.kind === 226) { + if (node.kind === 229 && + node.parent && node.parent.kind === 229) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_5 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 188 && + parent_5.kind === 191 && parent_5.operatorToken.kind === 57 && - parent_5.parent.kind === 203; + parent_5.parent.kind === 206; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 256; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 143) { + if (node.kind === 144) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7968,14 +8158,14 @@ var ts; var tags = getJSDocTags(func, checkParentVariableStatement); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); + var name_8 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 && tag.parameterName.text === name_8; }); if (paramTags) { return paramTags; } @@ -7985,15 +8175,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + return getJSDocTag(node, 281, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + return getJSDocTag(node, 280, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + return getJSDocTag(node, 282, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -8005,7 +8195,7 @@ var ts; } for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { + if (tag.kind === 279) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -8025,13 +8215,13 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { + if (node && (node.flags & 2097152)) { + if (node.type && node.type.kind === 274) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; + return paramTag.typeExpression.type.kind === 274; } } return isDeclaredRestParam(node); @@ -8041,27 +8231,44 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 179) { - node = node.parent; - } + function getAssignmentTargetKind(node) { + var parent = node.parent; while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 171 || parent_6.kind === 192) { - node = parent_6; - continue; + switch (parent.kind) { + case 191: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 189: + case 190: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 211: + case 212: + return parent.initializer === node ? 1 : 0; + case 182: + case 174: + case 195: + node = parent; + break; + case 257: + if (parent.name !== node) { + return 0; + } + case 256: + node = parent.parent; + break; + default: + return 0; } - if (parent_6.kind === 253 || parent_6.kind === 254) { - node = parent_6.parent; - continue; - } - return parent_6.kind === 188 && - isAssignmentOperator(parent_6.operatorToken.kind) && - parent_6.left === node || - (parent_6.kind === 208 || parent_6.kind === 209) && - parent_6.initializer === node; + parent = node.parent; } } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } ts.isAssignmentTarget = isAssignmentTarget; function isNodeDescendantOf(node, ancestor) { while (node) { @@ -8074,7 +8281,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 260 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8087,7 +8294,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { + if (parent.kind === 238 || parent.kind === 242) { if (parent.propertyName) { return true; } @@ -8100,48 +8307,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 141 && + node.parent.kind === 142 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 146: - case 145: - case 148: case 147: - case 150: + case 146: + case 149: + case 148: case 151: - case 255: - case 253: - case 173: + case 152: + case 259: + case 256: + case 176: return parent.name === node; - case 140: + case 141: if (parent.right === node) { - while (parent.kind === 140) { + while (parent.kind === 141) { parent = parent.parent; } - return parent.kind === 159; + return parent.kind === 160; } return false; - case 170: - case 235: + case 173: + case 238: return parent.propertyName === node; - case 239: + case 242: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 230 || - node.kind === 229 || - node.kind === 232 && !!node.name || - node.kind === 233 || - node.kind === 235 || - node.kind === 239 || - node.kind === 236 && exportAssignmentIsAlias(node); + return node.kind === 233 || + node.kind === 232 || + node.kind === 235 && !!node.name || + node.kind === 236 || + node.kind === 238 || + node.kind === 242 || + node.kind === 239 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8227,7 +8434,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 139; + return 71 <= token && token <= 140; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8247,7 +8454,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 && + return name.kind === 142 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8257,10 +8464,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { return name.text; } - if (name.kind === 141) { + if (name.kind === 142) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8296,7 +8503,7 @@ var ts; case 113: case 111: case 112: - case 129: + case 130: case 114: return true; } @@ -8305,11 +8512,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 143; + return root.kind === 144; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 170) { + while (node.kind === 173) { node = node.parent.parent; } return node; @@ -8317,15 +8524,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 149 - || kind === 180 - || kind === 221 - || kind === 181 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 183 + || kind === 224 + || kind === 184 + || kind === 149 || kind === 151 - || kind === 226 - || kind === 256; + || kind === 152 + || kind === 229 + || kind === 260; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8333,13 +8540,13 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { + function getOriginalNode(node, nodeTest) { if (node) { while (node.original !== undefined) { node = node.original; } } - return node; + return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; function isParseTreeNode(node) { @@ -8376,23 +8583,23 @@ var ts; ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176: + case 179: return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: case 189: - case 191: - return 1; + case 186: + case 187: + case 185: case 188: + case 192: + case 194: + return 1; + case 191: switch (operator) { case 39: case 57: @@ -8416,15 +8623,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188) { + if (expression.kind === 191) { return expression.operatorToken.kind; } - else if (expression.kind === 186 || expression.kind === 187) { + else if (expression.kind === 189 || expression.kind === 190) { return expression.operator; } else { @@ -8442,36 +8649,36 @@ var ts; case 85: case 8: case 9: - case 171: - case 172: - case 180: - case 181: - case 193: - case 242: - case 243: - case 11: - case 12: - case 190: - case 179: - case 194: - return 19; - case 177: - case 173: case 174: - return 18; - case 176: - return hasArguments ? 18 : 17; case 175: - return 17; - case 187: - return 16; - case 186: case 183: case 184: + case 196: + case 245: + case 246: + case 11: + case 12: + case 193: case 182: + case 197: + return 19; + case 180: + case 176: + case 177: + return 18; + case 179: + return hasArguments ? 18 : 17; + case 178: + return 17; + case 190: + return 16; + case 189: + case 186: + case 187: case 185: - return 15; case 188: + return 15; + case 191: switch (operatorKind) { case 50: case 51: @@ -8529,11 +8736,11 @@ var ts; default: return -1; } - case 189: - return 4; - case 191: - return 2; case 192: + return 4; + case 194: + return 2; + case 195: return 1; default: return -1; @@ -8779,13 +8986,16 @@ var ts; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); + var sourceFiles = getAllEmittableSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; return ts.filter(sourceFiles, isNonDeclarationFile); } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } } ts.getSourceFilesToEmit = getSourceFilesToEmit; function isNonDeclarationFile(sourceFile) { @@ -8843,7 +9053,7 @@ var ts; onBundledEmit(host); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { @@ -8873,7 +9083,7 @@ var ts; action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || !!ts.getEmitModuleKind(options)); }); @@ -8913,7 +9123,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 149 && nodeIsPresent(member.body)) { + if (member.kind === 150 && nodeIsPresent(member.body)) { return member; } }); @@ -8954,10 +9164,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 150) { + if (accessor.kind === 151) { getAccessor = accessor; } - else if (accessor.kind === 151) { + else if (accessor.kind === 152) { setAccessor = accessor; } else { @@ -8966,7 +9176,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 150 || member.kind === 151) + if ((member.kind === 151 || member.kind === 152) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8977,10 +9187,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 150 && !getAccessor) { + if (member.kind === 151 && !getAccessor) { getAccessor = member; } - if (member.kind === 151 && !setAccessor) { + if (member.kind === 152 && !setAccessor) { setAccessor = member; } } @@ -9182,7 +9392,7 @@ var ts; case 75: return 2048; case 78: return 512; case 119: return 256; - case 129: return 64; + case 130: return 64; } return 0; } @@ -9198,19 +9408,25 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && + if (node.kind === 198 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node) { + return isBinaryExpression(node) + && isAssignmentOperator(node.operatorToken.kind) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 172 - || kind === 171; + return kind === 175 + || kind === 174; } } return false; @@ -9237,20 +9453,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 173 && isEntityNameExpression(node.expression); + node.kind === 176 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 140 && node.parent.right === node) || - (node.parent.kind === 173 && node.parent.name === node); + return (node.parent.kind === 141 && node.parent.right === node) || + (node.parent.kind === 176 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172) { + if (kind === 175) { return expression.properties.length === 0; } - if (kind === 171) { + if (kind === 174) { return expression.elements.length === 0; } return false; @@ -9384,39 +9600,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 173) { + else if (kind === 176) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174) { + else if (kind === 177) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 - || kind === 187) { + else if (kind === 189 + || kind === 190) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188) { + else if (kind === 191) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189) { + else if (kind === 192) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 184 - || kind === 183 - || kind === 182) { + else if (kind === 187 + || kind === 186 + || kind === 185) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171) { + else if (kind === 174) { return node.elements.length === 0; } - else if (kind === 172) { + else if (kind === 175) { return node.properties.length === 0; } - else if (kind === 175) { + else if (kind === 178) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9438,9 +9654,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; + for (var name_9 in syntaxKindEnum) { + if (syntaxKindEnum[name_9] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; } } } @@ -9522,23 +9738,26 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile, resolver) { var externalImports = []; var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 231: + case 234: externalImports.push(node); break; - case 230: - if (node.moduleReference.kind === 241) { + case 233: + if (node.moduleReference.kind === 244) { externalImports.push(node); } break; - case 237: + case 240: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -9551,21 +9770,102 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); + if (!uniqueExports[specifier.name.text]) { + var name_10 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_10) + || resolver.getReferencedValueDeclaration(name_10); + if (decl) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = specifier.name; + } } } break; - case 236: + case 239: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; + case 204: + if (hasModifier(node, 1)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + collectExportedVariableInfo(decl, uniqueExports); + } + } + break; + case 224: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_11 = node.name; + if (!uniqueExports[name_11.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_11); + uniqueExports[name_11.text] = name_11; + } + } + } + break; + case 225: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_12 = node.name; + if (!uniqueExports[name_12.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_12); + uniqueExports[name_12.text] = name_12; + } + } + } + break; } } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + var exportedNames; + for (var key in uniqueExports) { + exportedNames = ts.append(exportedNames, uniqueExports[key]); + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; } ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports) { + if (isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!isOmittedExpression(element)) { + collectExportedVariableInfo(element, uniqueExports); + } + } + } + else if (!isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = decl.name; + } + } + } + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 228: + case 229: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9577,7 +9877,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && declaration !== node) { + if (declaration.kind === 225 && declaration !== node) { return true; } } @@ -9637,16 +9937,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 140 + return kind === 141 || kind === 70; } ts.isEntityName = isEntityName; @@ -9655,7 +9955,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 141; + || kind === 142; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9667,57 +9967,58 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 168 - || kind === 169; + || kind === 171 + || kind === 172; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 144; + return node.kind === 145; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 148; + return node.kind === 149; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 149 - || kind === 146 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 147 + || kind === 149 || kind === 151 - || kind === 154 - || kind === 199; + || kind === 152 + || kind === 155 + || kind === 202; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 + return kind === 256 + || kind === 257 + || kind === 258 + || kind === 149 || kind === 151 - || kind === 240; + || kind === 152 + || kind === 243; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) + return (kind >= 156 && kind <= 170) || kind === 118 - || kind === 131 + || kind === 132 || kind === 121 - || kind === 133 || kind === 134 + || kind === 135 || kind === 104 - || kind === 128 - || kind === 195; + || kind === 129 + || kind === 198; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -9726,94 +10027,102 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 - || kind === 168; + return kind === 172 + || kind === 171; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170; + return node.kind === 173; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 - || kind === 194; + return kind === 173 + || kind === 197; } ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 174; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 175; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173; + return node.kind === 176; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174; + return node.kind === 177; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188; + return node.kind === 191; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189; + return node.kind === 192; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175; + return node.kind === 178; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 + return kind === 193 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { + function isSpreadExpression(node) { return node.kind === 195; } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 198; + } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 + return kind === 176 || kind === 177 - || kind === 171 || kind === 179 - || kind === 172 - || kind === 193 + || kind === 178 + || kind === 245 + || kind === 246 || kind === 180 + || kind === 174 + || kind === 182 + || kind === 175 + || kind === 196 + || kind === 183 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 190 + || kind === 193 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 197; + || kind === 200; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 - || kind === 187 - || kind === 182 - || kind === 183 - || kind === 184 + return kind === 189 + || kind === 190 || kind === 185 - || kind === 178 + || kind === 186 + || kind === 187 + || kind === 188 + || kind === 181 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9821,13 +10130,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 - || kind === 192 - || kind === 196 + return kind === 192 || kind === 194 + || kind === 184 + || kind === 191 + || kind === 195 + || kind === 199 + || kind === 197 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9836,16 +10145,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 - || kind === 196; + return kind === 181 + || kind === 199; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288; + return node.kind === 292; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287; + return node.kind === 291; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9854,15 +10163,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194; + return node.kind === 197; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 198; + return node.kind === 201; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 200; + return node.kind === 203; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9880,119 +10189,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219; + return node.kind === 222; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220; + return node.kind === 223; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228; + return node.kind === 231; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 - || kind === 226; + return kind === 230 + || kind === 229; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230; + return node.kind === 233; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232; + return node.kind === 235; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 - || kind === 233; + return kind === 237 + || kind === 236; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235; + return node.kind === 238; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238; + return node.kind === 241; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239; + return node.kind === 242; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; + return node.kind === 229 || node.kind === 228; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 + return kind === 184 + || kind === 173 || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 + || kind === 196 || kind === 150 - || kind === 232 - || kind === 230 - || kind === 235 - || kind === 223 - || kind === 148 - || kind === 147 - || kind === 226 - || kind === 229 - || kind === 233 - || kind === 143 - || kind === 253 - || kind === 146 - || kind === 145 - || kind === 151 - || kind === 254 + || kind === 228 + || kind === 259 + || kind === 242 || kind === 224 - || kind === 142 - || kind === 219 - || kind === 279; + || kind === 183 + || kind === 151 + || kind === 235 + || kind === 233 + || kind === 238 + || kind === 226 + || kind === 149 + || kind === 148 + || kind === 229 + || kind === 232 + || kind === 236 + || kind === 144 + || kind === 256 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 257 + || kind === 227 + || kind === 143 + || kind === 222 + || kind === 283; } function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 + return kind === 224 + || kind === 243 || kind === 225 || kind === 226 - || kind === 231 - || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; + || kind === 227 + || kind === 228 + || kind === 229 + || kind === 234 + || kind === 233 + || kind === 240 + || kind === 239 + || kind === 232; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 - || kind === 210 - || kind === 218 - || kind === 205 - || kind === 203 - || kind === 202 - || kind === 208 - || kind === 209 - || kind === 207 - || kind === 204 - || kind === 215 - || kind === 212 - || kind === 214 - || kind === 216 - || kind === 217 - || kind === 201 - || kind === 206 + return kind === 214 || kind === 213 - || kind === 287; + || kind === 221 + || kind === 208 + || kind === 206 + || kind === 205 + || kind === 211 + || kind === 212 + || kind === 210 + || kind === 207 + || kind === 218 + || kind === 215 + || kind === 217 + || kind === 219 + || kind === 220 + || kind === 204 + || kind === 209 + || kind === 216 + || kind === 291 + || kind === 294 + || kind === 293; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10010,87 +10321,87 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200; + || kind === 203; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 241 - || kind === 140 + return kind === 244 + || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 244; + return node.kind === 247; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245; + return node.kind === 248; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 173; + || kind === 176; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 + return kind === 245 + || kind === 251 + || kind === 246 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 - || kind === 247; + return kind === 249 + || kind === 250; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247; + return node.kind === 250; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246; + return node.kind === 249; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 248; + || kind === 251; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 - || kind === 250; + return kind === 252 + || kind === 253; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251; + return node.kind === 254; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252; + return node.kind === 255; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 253; + return node.kind === 256; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254; + return node.kind === 257; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 256; + return node.kind === 260; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10101,6 +10412,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5: case 4: return "lib.es2017.d.ts"; case 3: @@ -10228,9 +10540,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 142) { + if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 226) { return current; } } @@ -10238,11 +10550,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 || ts.isBindingPattern(node))) { + while (node && (node.kind === 173 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10250,14 +10562,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= ts.getModifierFlags(node); } return flags; @@ -10266,14 +10578,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= node.flags; } return flags; @@ -10285,7 +10597,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 260 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10455,7 +10767,7 @@ var ts; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(141, location); + var node = createNode(142, location); node.expression = expression; return node; } @@ -10467,12 +10779,8 @@ var ts; return node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(name, initializer, location) { - return createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(143, location, flags); + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(144, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10482,16 +10790,16 @@ var ts; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + ts.createParameter = createParameter; + function updateParameter(node, decorators, modifiers, name, type, initializer) { if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); + return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; + ts.updateParameter = updateParameter; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(146, location); + var node = createNode(147, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10509,7 +10817,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10529,7 +10837,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10547,7 +10855,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10566,7 +10874,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(151, location, flags); + var node = createNode(152, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10584,7 +10892,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(171, location); node.elements = createNodeArray(elements); return node; } @@ -10597,7 +10905,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -10610,7 +10918,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(173, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10626,7 +10934,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(174, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10642,7 +10950,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(175, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10658,7 +10966,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10675,7 +10983,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(177, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10689,7 +10997,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(178, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10706,7 +11014,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10721,7 +11029,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(180, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10735,7 +11043,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(182, location); node.expression = expression; return node; } @@ -10748,7 +11056,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(183, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10767,7 +11075,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(181, location, flags); + var node = createNode(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10785,7 +11093,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10798,7 +11106,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10811,7 +11119,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10824,7 +11132,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10837,7 +11145,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(189, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10851,7 +11159,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(190, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10867,7 +11175,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(188, location); + var node = createNode(191, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10882,7 +11190,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(192, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10899,7 +11207,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(193, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10913,7 +11221,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(194, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10927,7 +11235,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(195, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10940,7 +11248,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(196, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10958,12 +11266,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(197, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(198, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10977,7 +11285,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(201, location); node.expression = expression; node.literal = literal; return node; @@ -10991,7 +11299,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(203, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11007,7 +11315,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(204, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11022,7 +11330,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(223, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11035,7 +11343,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(222, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11050,11 +11358,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(205, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(206, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11067,7 +11375,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(207, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11082,7 +11390,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(208, location); node.statement = statement; node.expression = expression; return node; @@ -11096,7 +11404,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(209, location); node.expression = expression; node.statement = statement; return node; @@ -11110,7 +11418,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(210, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11126,7 +11434,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(211, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11141,7 +11449,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11156,7 +11464,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(213, location); if (label) { node.label = label; } @@ -11171,7 +11479,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -11186,7 +11494,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(215, location); node.expression = expression; return node; } @@ -11199,7 +11507,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(216, location); node.expression = expression; node.statement = statement; return node; @@ -11213,7 +11521,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(217, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11227,7 +11535,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(218, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11241,7 +11549,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(219, location); node.expression = expression; return node; } @@ -11254,7 +11562,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(220, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11269,7 +11577,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(231, location); node.clauses = createNodeArray(clauses); return node; } @@ -11282,7 +11590,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(221, location, flags); + var node = createNode(224, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11302,7 +11610,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(225, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11320,7 +11628,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(234, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11336,7 +11644,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(235, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11350,7 +11658,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(236, location); node.name = name; return node; } @@ -11363,7 +11671,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(237, location); node.elements = createNodeArray(elements); return node; } @@ -11376,7 +11684,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(238, location); node.propertyName = propertyName; node.name = name; return node; @@ -11390,7 +11698,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(239, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11406,7 +11714,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11422,7 +11730,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(241, location); node.elements = createNodeArray(elements); return node; } @@ -11435,7 +11743,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(242, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11449,7 +11757,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(245, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11464,7 +11772,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(246, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11478,7 +11786,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11492,7 +11800,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(248, location); node.tagName = tagName; return node; } @@ -11505,7 +11813,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(249, location); node.name = name; node.initializer = initializer; return node; @@ -11519,7 +11827,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(250, location); node.expression = expression; return node; } @@ -11532,7 +11840,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -11545,7 +11853,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(254, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11559,7 +11867,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(252, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11573,7 +11881,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(253, location); node.statements = createNodeArray(statements); return node; } @@ -11586,7 +11894,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(255, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11600,7 +11908,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(256, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11615,12 +11923,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function createSpreadAssignment(expression, location) { + var node = createNode(258, location); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); @@ -11628,9 +11942,16 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSpreadAssignment(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpreadAssignment(expression, node), node); + } + return node; + } + ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(256, node, node.flags); + var updated = createNode(260, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11692,13 +12013,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(291, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(293); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(292, location || original); node.expression = expression; node.original = original; return node; @@ -11770,10 +12105,6 @@ var ts; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); - } - ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { return createCall(createPropertyAccess(func, "call"), undefined, [ thisArg @@ -11809,7 +12140,20 @@ var ts; react.parent = ts.getParseTreeNode(parent); return react; } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536)); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -11829,9 +12173,21 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), undefined, argumentsList, location); + return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); } - ts.createReactCreateElement = createReactCreateElement; + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function createExportDefault(expression) { + return createExportAssignment(undefined, undefined, false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function createLetStatement(name, initializer, location) { + return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + } + ts.createLetStatement = createLetStatement; function createLetDeclarationList(declarations, location) { return createVariableDeclarationList(declarations, location, 1); } @@ -11903,13 +12259,13 @@ var ts; return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); } function createGeti(target) { - return createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createElementAccess(target, createIdentifier("name"))); + return createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createElementAccess(target, createIdentifier("name"))); } function createSeti(target) { return createArrowFunction(undefined, undefined, [ - createParameter("name"), - createParameter("value") - ], undefined, undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); + createParameter(undefined, undefined, undefined, "name"), + createParameter(undefined, undefined, undefined, "value") + ], undefined, createToken(35), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } function createAdvancedAsyncSuperHelper() { var createCache = createVariableStatement(undefined, createConstDeclarationList([ @@ -11918,20 +12274,20 @@ var ts; var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) ])); - var setter = createSetAccessor(undefined, undefined, "value", [createParameter("v")], createBlock([ + var setter = createSetAccessor(undefined, undefined, "value", [createParameter(undefined, undefined, undefined, "v")], createBlock([ createStatement(createCall(createIdentifier("seti"), undefined, [ createIdentifier("name"), createIdentifier("v") ])) ])); - var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ getter, setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ - createParameter("geti"), - createParameter("seti") + createParameter(undefined, undefined, undefined, "geti"), + createParameter(undefined, undefined, undefined, "seti") ], undefined, createBlock([ createCache, getOrCreateAccessorsForName @@ -11957,13 +12313,13 @@ var ts; case 8: case 9: return false; - case 171: + case 174: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 175: return target.properties.length > 0; default: return true; @@ -11983,7 +12339,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 176: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11994,7 +12350,7 @@ var ts; } break; } - case 174: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -12044,14 +12400,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 150: case 151: + case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253: + case 256: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 257: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12092,6 +12448,59 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 262144); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (getEmitFlags(node) & 262144) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 131072); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (getEmitFlags(node) & 131072) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name_13 = getMutableClone(node.name); + emitFlags |= getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(name_13, emitFlags); + return name_13; + } + return getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } @@ -12153,7 +12562,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 182) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12162,15 +12571,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(191, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(191, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 191) { + && operand.kind === 194) { return false; } return true; @@ -12209,7 +12618,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 191 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12226,9 +12635,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 178: return createParen(expression); - case 176: + case 179: return emittedExpression.arguments ? expression : createParen(expression); @@ -12239,7 +12648,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 179 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -12277,7 +12686,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(188, 25); + var commaPrecedence = ts.getOperatorPrecedence(191, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -12288,7 +12697,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 183 || kind === 184) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12296,7 +12705,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 175 || leftmostExpressionKind === 183) { return createParen(expression, expression); } } @@ -12314,21 +12723,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 190: node = node.operand; continue; - case 188: + case 191: node = node.left; continue; - case 189: + case 192: node = node.condition; continue; - case 175: - case 174: - case 173: + case 178: + case 177: + case 176: node = node.expression; continue; - case 288: + case 292: node = node.expression; continue; } @@ -12337,7 +12746,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 175) { return createParen(body, body); } return body; @@ -12362,7 +12771,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 182) { node = node.expression; } return node; @@ -12376,7 +12785,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 292) { node = node.expression; } return node; @@ -12432,7 +12841,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 260) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12522,13 +12931,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_14 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_14) ? name_14 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 231 && node.importClause) { + if (node.kind === 234 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 240 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12566,6 +12975,221 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } + function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + context.startLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = addPrologueDirectives(statements, body.statements, false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); + addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 184); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = createReturn(expression, body); + setEmitFlags(returnStatement, 12288 | 1024 | 32768); + statements.push(returnStatement); + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + setEmitFlags(block, 32); + } + if (closeBraceLocation) { + setTokenSourceMapRange(block, 17, closeBraceLocation); + } + setOriginalNode(block, node.body); + return block; + } + ts.transformFunctionBody = transformFunctionBody; + function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { + if (node.transformFlags & 524288 && node.kind !== 184) { + captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + } + } + ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; + function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + setEmitFlags(captureThisStatement, 49152 | 8388608); + setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + ts.captureThisForNode = captureThisForNode; + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 2097152) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_15 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_15)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_15, initializer, visitor, convertObjectRest); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_15, initializer, visitor); + } + } + } + ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { + var temp = getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608)); + } + else if (initializer) { + statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + } + } + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ + createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536), setEmitFlags(initializer, 1536 | getEmitFlags(initializer)), parameter)) + ], parameter), 32 | 1024 | 12288), undefined, parameter); + statement.startsOnNewLine = true; + setEmitFlags(statement, 12288 | 1024 | 8388608); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + var declarationName = getMutableClone(parameter.name); + setEmitFlags(declarationName, 1536); + var expressionName = getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = createLoopVariable(); + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration(declarationName, undefined, createArrayLiteral([])) + ]), parameter), 8388608)); + var forStatement = createFor(createVariableDeclarationList([ + createVariableDeclaration(temp, undefined, createLiteral(restIndex)) + ], parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), parameter), createPostfixIncrement(temp, parameter), createBlock([ + startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), parameter)) + ])); + setEmitFlags(forStatement, 8388608); + startOnNewLine(forStatement); + statements.push(forStatement); + } + ts.addRestParameterIfNeeded = addRestParameterIfNeeded; + function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = convertObjectRest ? undefined : createLoopVariable(); + var rhsReference = expression.kind === 70 + ? createUniqueName(expression.text) + : createTempVariable(undefined); + var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, undefined, convertObjectRest); + var declarationList = createVariableDeclarationList(declarations, initializer); + setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(createVariableStatement(undefined, declarationList)); + } + else { + statements.push(createVariableStatement(undefined, setOriginalNode(createVariableDeclarationList([ + createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(undefined), undefined, createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + } + } + else { + var assignment = createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, false, context.hoistVariableDeclaration, visitor, convertObjectRest))); + } + else { + assignment.end = initializer.end; + statements.push(createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + setEmitFlags(expression, 1536 | getEmitFlags(expression)); + var body = createBlock(createNodeArray(statements, statementsLocation), bodyLocation); + setEmitFlags(body, 1536 | 12288); + var forStatement; + if (convertObjectRest) { + forStatement = createForOf(createVariableDeclarationList([ + createVariableDeclaration(rhsReference, undefined, undefined, node.expression) + ], node.expression), node.expression, body, node); + } + else { + forStatement = createFor(setEmitFlags(createVariableDeclarationList([ + createVariableDeclaration(counter, undefined, createLiteral(0), ts.moveRangePos(node.expression, -1)), + createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), 16777216), createLessThan(counter, createPropertyAccess(rhsReference, "length"), node.expression), createPostfixIncrement(counter, node.expression), body, node); + } + setEmitFlags(forStatement, 8192); + return forStatement; + } + ts.convertForOf = convertForOf; })(ts || (ts = {})); var ts; (function (ts) { @@ -12574,13 +13198,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 260) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 140) { + else if (kind < 141) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12616,26 +13240,28 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 140: + case 141: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 142: + case 143: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 254: + case 257: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 143: + case 258: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 256: + case 222: + case 173: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12644,24 +13270,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 157: case 158: - case 152: + case 159: case 153: case 154: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 180: - case 221: - case 181: + case 152: + case 183: + case 224: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12672,309 +13298,313 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 156: + case 157: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 155: + case 156: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 159: - return visitNode(cbNode, node.exprName); case 160: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 161: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 162: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 163: + return visitNodes(cbNodes, node.elementTypes); case 164: - return visitNodes(cbNodes, node.types); case 165: - return visitNode(cbNode, node.type); - case 167: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 166: case 168: + return visitNode(cbNode, node.type); case 169: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.objectType) || + visitNode(cbNode, node.indexType); + case 170: + return visitNode(cbNode, node.literal); case 171: - return visitNodes(cbNodes, node.elements); case 172: + return visitNodes(cbNodes, node.elements); + case 174: + return visitNodes(cbNodes, node.elements); + case 175: return visitNodes(cbNodes, node.properties); - case 173: + case 176: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 178: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 180: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 181: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179: - return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 186: - return visitNode(cbNode, node.operand); - case 191: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 185: return visitNode(cbNode, node.expression); + case 186: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.expression); + case 189: return visitNode(cbNode, node.operand); + case 194: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 191: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 199: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 200: return visitNode(cbNode, node.expression); - case 189: + case 192: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 195: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 203: + case 230: return visitNodes(cbNodes, node.statements); - case 256: + case 260: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 204: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 223: return visitNodes(cbNodes, node.declarations); - case 203: + case 206: return visitNode(cbNode, node.expression); - case 204: + case 207: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 208: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 210: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 209: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 210: case 211: - return visitNode(cbNode, node.label); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: + case 214: + return visitNode(cbNode, node.label); + case 215: + return visitNode(cbNode, node.expression); + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214: + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228: + case 231: return visitNodes(cbNodes, node.clauses); - case 249: + case 252: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250: + case 253: return visitNodes(cbNodes, node.statements); - case 215: + case 218: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216: + case 219: return visitNode(cbNode, node.expression); - case 217: + case 220: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 255: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 223: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 224: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); case 225: + case 196: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 255: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 226: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 227: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 228: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 259: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230: + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 235: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: + case 232: return visitNode(cbNode, node.name); - case 233: + case 236: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + case 241: + return visitNodes(cbNodes, node.elements); + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: - case 239: + case 238: + case 242: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 239: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 193: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 254: return visitNodes(cbNodes, node.types); - case 195: + case 198: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 244: return visitNode(cbNode, node.expression); - case 240: + case 243: return visitNodes(cbNodes, node.decorators); - case 242: + case 245: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 246: + case 247: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 249: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 250: + return visitNode(cbNode, node.expression); + case 251: return visitNode(cbNode, node.expression); case 248: - return visitNode(cbNode, node.expression); - case 245: return visitNode(cbNode, node.tagName); - case 257: - return visitNode(cbNode, node.type); case 261: - return visitNodes(cbNodes, node.types); - case 262: - return visitNodes(cbNodes, node.types); - case 260: - return visitNode(cbNode, node.elementType); - case 264: - return visitNode(cbNode, node.type); - case 263: return visitNode(cbNode, node.type); case 265: - return visitNode(cbNode, node.literal); - case 267: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 266: + return visitNodes(cbNodes, node.types); + case 264: + return visitNode(cbNode, node.elementType); case 268: return visitNode(cbNode, node.type); + case 267: + return visitNode(cbNode, node.type); case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 271: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 272: return visitNode(cbNode, node.type); - case 266: + case 273: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 270: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 277: return visitNodes(cbNodes, node.tags); - case 275: + case 279: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 280: return visitNode(cbNode, node.typeExpression); - case 277: + case 281: return visitNode(cbNode, node.typeExpression); - case 278: + case 282: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 283: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 285: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 284: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 292: return visitNode(cbNode, node.expression); - case 282: + case 286: return visitNode(cbNode, node.literal); } } @@ -12988,6 +13618,10 @@ var ts; return result; } ts.createSourceFile = createSourceFile; + function parseIsolatedEntityName(text, languageVersion) { + return Parser.parseIsolatedEntityName(text, languageVersion); + } + ts.parseIsolatedEntityName = parseIsolatedEntityName; function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -13010,8 +13644,8 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(4, true); - var disallowInAndDecoratorContext = 32768 | 131072; + var scanner = ts.createScanner(5, true); + var disallowInAndDecoratorContext = 65536 | 262144; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -13035,6 +13669,15 @@ var ts; return result; } Parser.parseSourceFile = parseSourceFile; + function parseIsolatedEntityName(content, languageVersion) { + initializeState(content, languageVersion, undefined, 1); + nextToken(); + var entityName = parseEntityName(true); + var isInvalid = token() === 1 && !parseDiagnostics.length; + clearState(); + return isInvalid ? entityName : undefined; + } + Parser.parseIsolatedEntityName = parseIsolatedEntityName; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } @@ -13050,7 +13693,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 1048576 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -13125,7 +13768,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(260, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13145,17 +13788,17 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 32768); - } - function setYieldContext(val) { setContextFlag(val, 65536); } - function setDecoratorContext(val) { + function setYieldContext(val) { setContextFlag(val, 131072); } - function setAwaitContext(val) { + function setDecoratorContext(val) { setContextFlag(val, 262144); } + function setAwaitContext(val) { + setContextFlag(val, 524288); + } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; if (contextFlagsToClear) { @@ -13177,41 +13820,41 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(32768, func); + return doOutsideOfContext(65536, func); } function disallowInAnd(func) { - return doInsideOfContext(32768, func); - } - function doInYieldContext(func) { return doInsideOfContext(65536, func); } - function doInDecoratorContext(func) { + function doInYieldContext(func) { return doInsideOfContext(131072, func); } - function doInAwaitContext(func) { + function doInDecoratorContext(func) { return doInsideOfContext(262144, func); } + function doInAwaitContext(func) { + return doInsideOfContext(524288, func); + } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144, func); + return doOutsideOfContext(524288, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 | 262144, func); + return doInsideOfContext(131072 | 524288, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(65536); - } - function inDisallowInContext() { - return inContext(32768); - } - function inDecoratorContext() { return inContext(131072); } - function inAwaitContext() { + function inDisallowInContext() { + return inContext(65536); + } + function inDecoratorContext() { return inContext(262144); } + function inAwaitContext() { + return inContext(524288); + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; @@ -13352,7 +13995,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + return kind >= 141 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -13372,7 +14015,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -13434,7 +14077,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(141); + var node = createNode(142); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -13504,9 +14147,11 @@ var ts; case 6: return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + case 17: + return isLiteralPropertyName(); case 9: - return token() === 20 || isLiteralPropertyName(); + return token() === 20 || token() === 23 || isLiteralPropertyName(); case 7: if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); @@ -13521,29 +14166,29 @@ var ts; return isIdentifierOrPattern(); case 10: return token() === 25 || token() === 23 || isIdentifierOrPattern(); - case 17: + case 18: return isIdentifier(); case 11: case 15: return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); - case 18: case 19: - return token() === 25 || isStartOfType(); case 20: - return isHeritageClause(); + return token() === 25 || isStartOfType(); case 21: + return isHeritageClause(); + case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; - case 22: case 23: - case 25: - return JSDocParser.isJSDocType(); case 24: + case 26: + return JSDocParser.isJSDocType(); + case 25: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -13587,7 +14232,7 @@ var ts; case 6: case 12: case 9: - case 21: + case 22: return token() === 17; case 3: return token() === 17 || token() === 72 || token() === 78; @@ -13595,31 +14240,32 @@ var ts; return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); - case 17: + case 18: return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: return token() === 19 || token() === 24; case 15: - case 19: + case 20: case 10: return token() === 21; case 16: + case 17: return token() === 19 || token() === 21; - case 18: + case 19: return token() !== 25; - case 20: + case 21: return token() === 16 || token() === 17; case 13: return token() === 28 || token() === 40; case 14: return token() === 26 && lookAhead(nextTokenIsSlash); - case 22: - return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 28 || token() === 17; - case 25: - return token() === 21 || token() === 17; + return token() === 19 || token() === 55 || token() === 17; case 24: + return token() === 28 || token() === 17; + case 26: + return token() === 21 || token() === 17; + case 25: return token() === 17; } } @@ -13636,7 +14282,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 26; kind++) { + for (var kind = 0; kind < 27; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -13687,7 +14333,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -13719,10 +14365,12 @@ var ts; return isReusableVariableDeclaration(node); case 16: return isReusableParameter(node); - case 20: case 17: - case 19: + return false; + case 21: case 18: + case 20: + case 19: case 11: case 12: case 7: @@ -13734,14 +14382,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 149: - case 154: case 150: + case 155: case 151: - case 146: - case 199: + case 152: + case 147: + case 202: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -13753,8 +14401,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 252: + case 253: return true; } } @@ -13763,65 +14411,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 224: case 204: case 203: - case 216: - case 212: - case 214: - case 211: - case 210: - case 208: - case 209: case 207: case 206: - case 213: - case 202: - case 217: + case 219: case 215: + case 217: + case 214: + case 213: + case 211: + case 212: + case 210: + case 209: + case 216: case 205: + case 220: case 218: - case 231: - case 230: - case 237: - case 236: - case 226: - case 222: - case 223: + case 208: + case 221: + case 234: + case 233: + case 240: + case 239: + case 229: case 225: - case 224: + case 226: + case 228: + case 227: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 153: - case 147: case 154: - case 145: - case 152: + case 148: + case 155: + case 146: + case 153: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 219) { + if (node.kind !== 222) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var parameter = node; @@ -13841,6 +14489,7 @@ var ts; case 1: return ts.Diagnostics.Declaration_or_statement_expected; case 2: return ts.Diagnostics.case_or_default_expected; case 3: return ts.Diagnostics.Statement_expected; + case 17: case 4: return ts.Diagnostics.Property_or_signature_expected; case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; case 6: return ts.Diagnostics.Enum_member_expected; @@ -13852,17 +14501,17 @@ var ts; case 12: return ts.Diagnostics.Property_assignment_expected; case 15: return ts.Diagnostics.Expression_or_comma_expected; case 16: return ts.Diagnostics.Parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18: return ts.Diagnostics.Type_argument_expected; - case 19: return ts.Diagnostics.Type_expected; - case 20: return ts.Diagnostics.Unexpected_token_expected; - case 21: return ts.Diagnostics.Identifier_expected; + case 18: return ts.Diagnostics.Type_parameter_declaration_expected; + case 19: return ts.Diagnostics.Type_argument_expected; + case 20: return ts.Diagnostics.Type_expected; + case 21: return ts.Diagnostics.Unexpected_token_expected; + case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; - case 22: return ts.Diagnostics.Parameter_declaration_expected; - case 23: return ts.Diagnostics.Type_argument_expected; - case 25: return ts.Diagnostics.Type_expected; - case 24: return ts.Diagnostics.Property_assignment_expected; + case 23: return ts.Diagnostics.Parameter_declaration_expected; + case 24: return ts.Diagnostics.Type_argument_expected; + case 26: return ts.Diagnostics.Type_expected; + case 25: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -13916,7 +14565,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(140, entity.pos); + var node = createNode(141, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13933,7 +14582,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(193); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -13945,7 +14594,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(201); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13993,33 +14642,33 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(156, typeName.pos); + var node = createNode(157, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(155, lhs.pos); + var node = createNode(156, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(166); + var node = createNode(167); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(159); + var node = createNode(160); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(142); + var node = createNode(143); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14033,7 +14682,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -14046,7 +14695,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(143); + var node = createNode(144); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14106,7 +14755,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14146,7 +14795,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(154, fullStart); + var node = createNode(155, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14158,7 +14807,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14167,7 +14816,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14207,10 +14856,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(152); + return parseSignatureMember(153); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(153); + return parseSignatureMember(154); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14224,7 +14873,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14240,12 +14889,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(162); - node.elementTypes = parseBracketedList(19, parseType, 20, 21); + var node = createNode(163); + node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(165); + var node = createNode(166); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -14253,7 +14902,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -14264,7 +14913,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(170); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14275,12 +14924,12 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: - case 136: - case 128: + case 132: + case 121: + case 135: + case 137: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -14317,16 +14966,16 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: case 98: case 102: - case 128: + case 129: case 16: case 20: case 26: @@ -14351,13 +15000,36 @@ var ts; function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { - parseExpected(21); - var node = createNode(161, type.pos); - node.elementType = type; - type = finishNode(node); + if (isStartOfType()) { + var node = createNode(169, type.pos); + node.objectType = type; + node.indexType = parseType(); + parseExpected(21); + type = finishNode(node); + } + else { + var node = createNode(162, type.pos); + node.elementType = type; + parseExpected(21); + type = finishNode(node); + } } return type; } + function parseTypeOperator(operator) { + var node = createNode(168); + parseExpected(operator); + node.operator = operator; + node.type = parseTypeOperatorOrHigher(); + return finishNode(node); + } + function parseTypeOperatorOrHigher() { + switch (token()) { + case 126: + return parseTypeOperator(126); + } + return parseArrayTypeOrHigher(); + } function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { var type = parseConstituentType(); if (token() === operator) { @@ -14373,10 +15045,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); + return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -14422,7 +15094,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(155, typePredicateVariable.pos); + var node = createNode(156, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14439,14 +15111,14 @@ var ts; } } function parseType() { - return doOutsideOfContext(327680, parseTypeWorker); + return doOutsideOfContext(655360, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(157); + return parseFunctionOrConstructorType(158); } if (token() === 93) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } return parseUnionTypeOrHigher(); } @@ -14565,7 +15237,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(194); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -14581,13 +15253,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(181, asyncModifier.pos); + node = createNode(184, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(184, identifier.pos); } - var parameter = createNode(143, identifier.pos); + var parameter = createNode(144, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -14721,7 +15393,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(184); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -14753,7 +15425,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(192, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14766,7 +15438,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 139; + return t === 91 || t === 140; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -14844,39 +15516,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(191, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(196, left.pos); + var node = createNode(199, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14891,7 +15563,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14907,7 +15579,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 181) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, 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 { @@ -14960,7 +15632,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14972,7 +15644,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(187, expression.pos); + var node = createNode(190, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14995,7 +15667,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(176, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15017,8 +15689,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 244) { - var node = createNode(242, opening.pos); + if (opening.kind === 247) { + var node = createNode(245, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15028,14 +15700,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 246); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(188, result.pos); + var badNode = createNode(191, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15088,7 +15760,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(247, fullStart); scanJsxText(); } else { @@ -15100,7 +15772,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(246, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15111,7 +15783,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15119,7 +15791,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(251); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -15138,7 +15810,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(249); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15153,7 +15825,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(250); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15161,7 +15833,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(248); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15174,7 +15846,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(181); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -15185,7 +15857,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15193,13 +15865,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(200, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(177, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -15213,7 +15885,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(180, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -15232,7 +15904,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -15240,7 +15912,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15259,7 +15931,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -15335,28 +16007,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(182); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(195); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(197) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(174); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15367,15 +16039,21 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(150, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(132)) { return parseAccessorDeclaration(151, fullStart, decorators, modifiers); } + else if (parseContextualModifier(133)) { + return parseAccessorDeclaration(152, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var dotDotDotToken = parseOptionalToken(23); + if (dotDotDotToken) { + var spreadElement = createNode(258, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -15391,7 +16069,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(257, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -15402,7 +16080,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(256, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -15412,7 +16090,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(175); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15426,7 +16104,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(183); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -15448,7 +16126,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(179); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -15458,7 +16136,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(203); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15489,12 +16167,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(205); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(207); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15504,7 +16182,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(208); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -15515,7 +16193,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(209); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15538,21 +16216,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(211, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(139)) { - var forOfStatement = createNode(209, pos); + else if (parseOptional(140)) { + var forOfStatement = createNode(212, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(210, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -15570,7 +16248,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 214 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15578,7 +16256,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(215); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15587,7 +16265,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(216); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15596,7 +16274,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(252); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -15604,7 +16282,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(253); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -15614,12 +16292,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(217); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(231, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -15627,14 +16305,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(219); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(220); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -15645,7 +16323,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(255); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15655,7 +16333,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(221); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -15664,13 +16342,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(215, fullStart); + var labeledStatement = createNode(218, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(206, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15699,10 +16377,10 @@ var ts; case 82: return true; case 108: - case 135: + case 136: return nextTokenIsIdentifierOnSameLine(); - case 126: case 127: + case 128: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 116: case 119: @@ -15710,13 +16388,13 @@ var ts; case 111: case 112: case 113: - case 129: + case 130: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 138: + case 139: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -15774,16 +16452,16 @@ var ts; case 119: case 123: case 108: - case 126: case 127: - case 135: - case 138: + case 128: + case 136: + case 139: return true; case 113: case 111: case 112: case 114: - case 129: + case 130: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15822,9 +16500,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(213); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(214); case 95: return parseReturnStatement(); case 106: @@ -15843,9 +16521,9 @@ var ts; return parseDeclaration(); case 119: case 108: - case 135: - case 126: + case 136: case 127: + case 128: case 123: case 75: case 82: @@ -15856,8 +16534,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15880,13 +16558,13 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 135: + case 136: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 138: - case 126: + case 139: case 127: + case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -15903,7 +16581,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(243, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15924,16 +16602,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(197); } - var node = createNode(170); + var node = createNode(173); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(173); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -15948,14 +16627,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(171); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(172); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -15974,7 +16653,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(222); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15983,7 +16662,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(223); switch (token()) { case 103: break; @@ -15997,7 +16676,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16012,7 +16691,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(204, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16020,7 +16699,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16033,7 +16712,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(149, pos); + var node = createNode(150, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16042,7 +16721,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16055,7 +16734,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16063,7 +16742,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(65536 | 32768, parseNonParameterInitializer); + : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -16096,7 +16775,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -16125,7 +16804,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { return true; } switch (token()) { @@ -16148,7 +16827,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(144, decoratorStart); + var decorator = createNode(145, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16205,7 +16884,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(202); nextToken(); return finishNode(result); } @@ -16230,16 +16909,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_16 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_16, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 196); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 225); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -16268,13 +16947,13 @@ var ts; } function parseHeritageClauses() { if (isHeritageClause()) { - return parseList(20, parseHeritageClause); + return parseList(21, parseHeritageClause); } return undefined; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(251); + var node = createNode(254); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -16283,10 +16962,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(198); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -16297,7 +16976,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -16308,10 +16987,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -16320,13 +16999,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(259, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -16341,7 +17020,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(230, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -16352,7 +17031,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -16364,10 +17043,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -16384,14 +17063,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 138) { + if (token() === 139) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(127)) { + else if (parseOptional(128)) { flags |= 16; } else { - parseExpected(126); + parseExpected(127); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16399,7 +17078,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -16409,11 +17088,11 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(232, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); @@ -16424,8 +17103,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 137) { - var importEqualsDeclaration = createNode(230, fullStart); + if (token() !== 25 && token() !== 138) { + var importEqualsDeclaration = createNode(233, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -16435,27 +17114,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(234, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137); + parseExpected(138); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(232, fullStart); + var importClause = createNode(235, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(237); } return finishNode(importClause); } @@ -16465,8 +17144,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(244); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -16483,7 +17162,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(236); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -16491,14 +17170,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 237 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(242); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(238); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16517,23 +17196,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 238 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(237, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(137); + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(238); - if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(137); + node.exportClause = parseNamedImportsOrExports(241); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16541,7 +17220,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(239, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -16620,10 +17299,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 230 && node.moduleReference.kind === 241 - || node.kind === 231 - || node.kind === 236 - || node.kind === 237 + || node.kind === 233 && node.moduleReference.kind === 244 + || node.kind === 234 + || node.kind === 239 + || node.kind === 240 ? node : undefined; }); @@ -16648,8 +17327,8 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState(content, 4, undefined, 1); - sourceFile = createSourceFile("file.js", 4, 1); + initializeState(content, 5, undefined, 1); + sourceFile = createSourceFile("file.js", 5, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16659,7 +17338,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(261, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -16670,12 +17349,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(265, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(272, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -16686,20 +17365,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(264, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(267, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(268, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -16733,14 +17412,14 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: case 94: - case 136: - case 128: + case 137: + case 129: return parseTokenNode(); case 9: case 8: @@ -16751,30 +17430,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(275); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(273); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -16784,7 +17463,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(143); + var parameter = createNode(144); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -16792,7 +17471,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(271); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -16812,7 +17491,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -16826,26 +17505,26 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(140, left.pos); + var result = createNode(141, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(265); + var result = createNode(269); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(268); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(266); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -16857,7 +17536,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(265); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -16873,12 +17552,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(262); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(286); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -16891,17 +17570,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(263, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(267, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState(content, 4, undefined, 1); + initializeState(content, 5, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -17034,7 +17713,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(277, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17141,7 +17820,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(278, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17196,7 +17875,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17207,20 +17886,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 276; })) { + if (ts.forEach(tags, function (t) { return t.kind === 280; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 277; })) { + if (ts.forEach(tags, function (t) { return t.kind === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -17235,7 +17914,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -17245,7 +17924,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(283, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -17259,11 +17938,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 271) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name_17 = jsDocTypeReference.name; + if (name_17.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17277,7 +17956,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(285, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -17318,7 +17997,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(226, pos); + var jsDocNamespaceNode = createNode(229, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -17362,19 +18041,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 278; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_18 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_18) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(142, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(143, name_18.pos); + typeParameter.name = name_18; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -17385,7 +18064,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -17704,16 +18383,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 226 || node.kind === 227) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 234 || node.kind === 233) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 230) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17729,7 +18408,7 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 229) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17838,7 +18517,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 229)) { symbol.valueDeclaration = node; } } @@ -17848,7 +18527,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 141) { + if (node.name.kind === 142) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17859,21 +18538,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 149: + case 150: return "__constructor"; - case 157: - case 152: - return "__call"; case 158: case 153: - return "__new"; + return "__call"; + case 159: case 154: + return "__new"; + case 155: return "__index"; - case 237: + case 240: return "__export"; - case 236: + case 239: return node.isExportEquals ? "export=" : "default"; - case 188: + case 191: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17885,20 +18564,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 224: + case 225: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 273: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 273); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 283: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 204) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -17942,7 +18621,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 239 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17962,7 +18641,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { + if (node.kind === 242 || (node.kind === 233 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17970,7 +18649,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 279 && + var isJSDocTypedefInJSDocNamespace = node.kind === 283 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18009,7 +18688,7 @@ var ts; var saveReturnTarget = currentReturnTarget; var saveActiveLabels = activeLabels; var saveHasExplicitReturn = hasExplicitReturn; - var isIIFE = containerFlags & 16 && !!ts.getImmediatelyInvokedFunctionExpression(node); + var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) && !!ts.getImmediatelyInvokedFunctionExpression(node); if (isIIFE) { currentReturnTarget = createBranchLabel(); } @@ -18025,13 +18704,13 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~32128; + node.flags &= ~64896; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 256) { + if (node.kind === 260) { node.flags |= emitFlags; } if (isIIFE) { @@ -18084,64 +18763,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 209: bindWhileStatement(node); break; - case 205: + case 208: bindDoStatement(node); break; - case 207: + case 210: bindForStatement(node); break; - case 208: - case 209: + case 211: + case 212: bindForInOrForOfStatement(node); break; - case 204: + case 207: bindIfStatement(node); break; - case 212: - case 216: + case 215: + case 219: bindReturnOrThrow(node); break; - case 211: - case 210: + case 214: + case 213: bindBreakOrContinueStatement(node); break; - case 217: + case 220: bindTryStatement(node); break; - case 214: + case 217: bindSwitchStatement(node); break; - case 228: + case 231: bindCaseBlock(node); break; - case 249: + case 252: bindCaseClause(node); break; - case 215: + case 218: bindLabeledStatement(node); break; - case 186: + case 189: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 190: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 191: bindBinaryExpressionFlow(node); break; - case 182: + case 185: bindDeleteExpressionFlow(node); break; - case 189: + case 192: bindConditionalExpressionFlow(node); break; - case 219: + case 222: bindVariableDeclarationFlow(node); break; - case 175: + case 178: bindCallExpressionFlow(node); break; default: @@ -18153,15 +18832,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return isNarrowableReference(expr); - case 175: + case 178: return hasNarrowableArgument(expr); - case 179: + case 182: return isNarrowingExpression(expr.expression); - case 188: + case 191: return isNarrowingBinaryExpression(expr); - case 186: + case 189: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -18169,7 +18848,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 176 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -18180,14 +18859,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 176 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 186 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -18208,9 +18887,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 182: return isNarrowableOperand(expr.expression); - case 188: + case 191: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -18304,33 +18983,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: - return parent.expression === node; case 207: - case 189: + case 209: + case 208: + return parent.expression === node; + case 210: + case 192: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 182) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 189 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 191 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 182 || + node.parent.kind === 189 && node.parent.operator === 50) { node = node.parent; } @@ -18372,8 +19051,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 218 + ? ts.lastOrUndefined(activeLabels) + : undefined; + var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); + var postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel(); addAntecedent(preDoLabel, currentFlow); currentFlow = preDoLabel; bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); @@ -18404,7 +19086,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 223) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18426,7 +19108,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 215) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18446,7 +19128,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 214 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18503,7 +19185,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 250; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 253; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -18564,11 +19246,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); + if (!node.statement || node.statement.kind !== 208) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 191 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18579,10 +19263,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 174) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 195) { bindAssignmentTargetFlow(e.expression); } else { @@ -18590,15 +19274,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 175) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 256) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 257) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 258) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -18650,9 +19337,9 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 57 && !ts.isAssignmentTarget(node)) { + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (node.left.kind === 174) { + if (operator === 57 && node.left.kind === 177) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18663,7 +19350,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { bindAssignmentTargetFlow(node.expression); } } @@ -18673,9 +19360,11 @@ var ts; var postExpressionLabel = createBranchLabel(); bindCondition(node.condition, trueLabel, falseLabel); currentFlow = finishFlowLabel(trueLabel); + bind(node.questionToken); bind(node.whenTrue); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(falseLabel); + bind(node.colonToken); bind(node.whenFalse); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(postExpressionLabel); @@ -18694,16 +19383,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { + if (node.initializer || node.parent.parent.kind === 211 || node.parent.parent.kind === 212) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 182) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 183 || expr.kind === 184) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18711,7 +19400,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18720,51 +19409,51 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: + case 196: case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; + case 228: + case 175: + case 161: + case 285: case 269: + return 1; case 226: - case 224: + return 1 | 64; + case 273: + case 229: + case 227: return 1 | 32; - case 256: + case 260: return 1 | 4 | 32; - case 148: + case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 149: - case 221: - case 147: case 150: + case 224: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return 1 | 4 | 32 | 8; - case 180: - case 181: + case 183: + case 184: return 1 | 4 | 32 | 8 | 16; - case 227: + case 230: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 255: + case 210: + case 211: + case 212: + case 231: return 2; - case 200: + case 203: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18780,36 +19469,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 229: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 260: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 196: case 225: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 228: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 175: + case 226: + case 269: + case 285: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 157: case 158: - case 152: + case 159: case 153: case 154: - case 148: - case 147: + case 155: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 269: + case 152: case 224: + case 183: + case 184: + case 273: + case 227: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18824,11 +19513,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 227)) { + var body = node.kind === 260 ? node : node.body; + if (body && (body.kind === 260 || body.kind === 230)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 237 || stat.kind === 236) { + if (stat.kind === 240 || stat.kind === 239) { return true; } } @@ -18904,11 +19593,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 70) { + if (prop.kind === 258 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 256 || prop.kind === 257 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18930,10 +19619,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 229: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 260: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19023,8 +19712,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 260 && + blockScopeContainer.kind !== 229 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19067,7 +19756,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 139) { + if (node.kind > 140) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -19107,23 +19796,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 279) { + while (parentNode && parentNode.kind !== 283) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 257)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 176: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 191: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -19146,115 +19835,131 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 255: return checkStrictModeCatchClause(node); - case 182: + case 185: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 190: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 189: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 216: return checkStrictModeWithStatement(node); - case 166: + case 167: seenThisKeyword = true; return; - case 155: + case 156: return checkTypePredicate(node); - case 142: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 143: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 144: return bindParameter(node); - case 219: - case 170: + case 222: + case 173: + if (node.dotDotDotToken && node.parent.kind === 171) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 270: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 284: return bindJSDocProperty(node); - case 253: - case 254: + case 256: + case 257: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 259: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 258: + case 250: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 175 && + root.parent.kind === 191 && + root.parent.operatorToken.kind === 57 && + root.parent.left === root) { + hasRest = true; + break; + } + root = root.parent; + } + emitFlags |= hasRest ? 32768 : 16384; return; - case 152: case 153: case 154: + case 155: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 148: - case 147: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 221: - return bindFunctionDeclaration(node); case 149: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 148: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 224: + return bindFunctionDeclaration(node); case 150: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 151: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 152: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 157: case 158: - case 269: + case 159: + case 273: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 285: + case 269: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: - return bindObjectLiteralExpression(node); - case 180: - case 181: - return bindFunctionExpression(node); case 175: + return bindObjectLiteralExpression(node); + case 183: + case 184: + return bindFunctionExpression(node); + case 178: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 196: + case 225: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 226: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: + case 283: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 224: + case 227: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: + case 228: return bindEnumDeclaration(node); - case 226: - return bindModuleDeclaration(node); - case 230: - case 233: - case 235: - case 239: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 229: - return bindNamespaceExportDeclaration(node); - case 232: - return bindImportClause(node); - case 237: - return bindExportDeclaration(node); + return bindModuleDeclaration(node); + case 233: case 236: + case 238: + case 242: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 232: + return bindNamespaceExportDeclaration(node); + case 235: + return bindImportClause(node); + case 240: + return bindExportDeclaration(node); + case 239: return bindExportAssignment(node); - case 256: + case 260: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 203: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 230: return updateStrictModeStatementList(node.statements); } } @@ -19263,7 +19968,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -19282,7 +19987,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 239 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19292,17 +19997,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 256) { + if (node.parent.kind !== 260) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_7 = node.parent; - if (!ts.isExternalModule(parent_7)) { + var parent_6 = node.parent; + if (!ts.isExternalModule(parent_6)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_7.isDeclarationFile) { + if (!parent_6.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -19341,11 +20046,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 224 || container.kind === 183) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 149) { + else if (container.kind === 150) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19385,7 +20090,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 225) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19503,15 +20208,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || - node.kind === 222 || - (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 205) || + node.kind === 225 || + (node.kind === 229 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 228 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 204 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19525,56 +20230,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: + case 178: return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: + return computeNewExpression(node, subtreeFlags); + case 229: + return computeModuleDeclaration(node, subtreeFlags); + case 182: return computeParenthesizedExpression(node, subtreeFlags); - case 188: + case 191: return computeBinaryExpression(node, subtreeFlags); - case 203: + case 206: return computeExpressionStatement(node, subtreeFlags); - case 143: + case 144: return computeParameter(node, subtreeFlags); - case 181: + case 184: return computeArrowFunction(node, subtreeFlags); - case 180: + case 183: return computeFunctionExpression(node, subtreeFlags); - case 221: + case 224: return computeFunctionDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclaration(node, subtreeFlags); - case 220: - return computeVariableDeclarationList(node, subtreeFlags); - case 201: - return computeVariableStatement(node, subtreeFlags); - case 215: - return computeLabeledStatement(node, subtreeFlags); case 222: + return computeVariableDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclarationList(node, subtreeFlags); + case 204: + return computeVariableStatement(node, subtreeFlags); + case 218: + return computeLabeledStatement(node, subtreeFlags); + case 225: return computeClassDeclaration(node, subtreeFlags); - case 193: + case 196: return computeClassExpression(node, subtreeFlags); - case 251: + case 254: return computeHeritageClause(node, subtreeFlags); - case 252: + case 255: return computeCatchClause(node, subtreeFlags); - case 195: + case 198: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); case 150: + return computeConstructor(node, subtreeFlags); + case 147: + return computePropertyDeclaration(node, subtreeFlags); + case 149: + return computeMethod(node, subtreeFlags); case 151: + case 152: return computeAccessor(node, subtreeFlags); - case 230: + case 233: return computeImportEquals(node, subtreeFlags); - case 173: + case 176: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19588,19 +20293,19 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576 + if (subtreeFlags & 8388608 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function isSuperOrSuperProperty(node, kind) { switch (kind) { case 96: return true; - case 173: - case 174: + case 176: + case 177: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -19612,27 +20317,28 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576) { - transformFlags |= 768; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 - && (leftKind === 172 - || leftKind === 171)) { - transformFlags |= 768 | 1024; + if (operatorTokenKind === 57 && leftKind === 175) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 174) { + transformFlags |= 3072 | 49152; } else if (operatorTokenKind === 39 || operatorTokenKind === 61) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19642,33 +20348,36 @@ var ts; var dotDotDotToken = node.dotDotDotToken; if (node.questionToken || node.type - || subtreeFlags & 8192 + || subtreeFlags & 65536 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 524288; + transformFlags |= 3 | 4194304; } - if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { - transformFlags |= 768 | 262144; + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + if (subtreeFlags & 67108864 || initializer || dotDotDotToken) { + transformFlags |= 3072 | 2097152; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 196 - || expressionKind === 178) { + if (expressionKind === 199 + || expressionKind === 181) { transformFlags |= 3; } - if (expressionTransformFlags & 1024) { - transformFlags |= 1024; + if (expressionTransformFlags & 16384) { + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19677,36 +20386,35 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 768; - if ((subtreeFlags & 548864) - || (modifierFlags & 1) + transformFlags = subtreeFlags | 3072; + if ((subtreeFlags & 4390912) || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; - if (subtreeFlags & 548864 + var transformFlags = subtreeFlags | 3072; + if (subtreeFlags & 4390912 || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84: - transformFlags |= 768; + transformFlags |= 3072; break; case 107: transformFlags |= 3; @@ -19716,23 +20424,23 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19741,10 +20449,10 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.decorators || ts.hasModifier(node, 2270) || node.typeParameters @@ -19753,13 +20461,13 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 48; + transformFlags |= 192; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19770,15 +20478,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 16384; + transformFlags |= 131072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -19788,27 +20496,27 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 33554432; - if (modifierFlags & 1) { - transformFlags |= 3 | 768; - } + transformFlags = subtreeFlags | 268435456; if (modifierFlags & 2270 || node.typeParameters || node.type) { transformFlags |= 3; } if (modifierFlags & 256) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19818,54 +20526,63 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (ts.hasModifier(node, 2270) || node.typeParameters || node.type) { transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 32768) { - transformFlags |= 65536; + if (subtreeFlags & 262144) { + transformFlags |= 524288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592227669; + return transformFlags & ~979719509; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; if (expressionKind === 96) { - transformFlags |= 32768; + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 168 || nameKind === 169) { - transformFlags |= 768 | 8388608; + if (nameKind === 171) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 172) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19876,24 +20593,21 @@ var ts; } else { transformFlags = subtreeFlags; - if (modifierFlags & 1) { - transformFlags |= 768 | 3; - } - if (declarationListTransformFlags & 8388608) { - transformFlags |= 768; + if (declarationListTransformFlags & 67108864) { + transformFlags |= 3072; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 4194304 + if (subtreeFlags & 33554432 && ts.isIterationStatement(node, true)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19901,15 +20615,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 1024) { - transformFlags |= 768; + if (node.expression.transformFlags & 16384) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19918,26 +20632,26 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~574729557; + return transformFlags & ~839734613; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 33554432; - if (subtreeFlags & 8388608) { - transformFlags |= 768; + var transformFlags = subtreeFlags | 268435456; + if (subtreeFlags & 67108864) { + transformFlags |= 3072; } if (node.flags & 3) { - transformFlags |= 768 | 4194304; + transformFlags |= 3072 | 33554432; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536874325; + var excludeFlags = 536892757; switch (kind) { case 119: - case 185: - transformFlags |= 48; + case 188: + transformFlags |= 192; break; case 113: case 111: @@ -19945,52 +20659,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 228: + case 259: + case 181: + case 199: + case 200: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: case 245: case 246: case 247: + case 10: case 248: + case 249: + case 250: + case 251: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 212: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 193: + case 180: + case 257: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 194: + transformFlags |= 3072 | 134217728; break; case 118: - case 131: - case 128: - case 133: - case 121: + case 132: + case 129: case 134: + case 121: + case 135: case 104: - case 142: - case 145: - case 147: - case 152: + case 143: + case 146: + case 148: case 153: case 154: case 155: @@ -20004,122 +20715,138 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 226: + case 227: case 167: + case 168: + case 169: + case 170: transformFlags = 3; excludeFlags = -3; break; - case 141: - transformFlags |= 2097152; - if (subtreeFlags & 32768) { - transformFlags |= 131072; + case 142: + transformFlags |= 16777216; + if (subtreeFlags & 262144) { + transformFlags |= 1048576; } break; - case 192: - transformFlags |= 1048576; + case 195: + case 258: + transformFlags |= 8388608; break; + case 173: + if (node.dotDotDotToken) { + transformFlags |= 8388608; + } case 96: - transformFlags |= 768; + transformFlags |= 3072; break; case 98: - transformFlags |= 32768; - break; - case 168: - case 169: - transformFlags |= 768 | 8388608; - break; - case 144: - transformFlags |= 3 | 8192; - break; - case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; - } - if (subtreeFlags & 131072) { - transformFlags |= 32768; - } + transformFlags |= 262144; break; case 171: - case 176: - excludeFlags = 537922901; + case 172: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; + } + else { + transformFlags |= 3072 | 67108864; + } + break; + case 145: + transformFlags |= 3 | 65536; + break; + case 175: + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + break; + case 174: + case 179: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 205: - case 206: - case 207: case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; - } - break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 260: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 215: + case 213: + case 214: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { + if (kind >= 156 && kind <= 170) { return -3; } switch (kind) { - case 175: - case 176: - case 171: - return 537922901; - case 226: - return 574729557; - case 143: - return 545262933; - case 181: - return 592227669; - case 180: - case 221: - return 592293205; - case 220: - return 545262933; - case 222: - case 193: - return 539749717; - case 149: - return 591760725; - case 148: + case 178: + case 179: + case 174: + return 545281365; + case 229: + return 839734613; + case 144: + return 604001621; + case 184: + return 979719509; + case 183: + case 224: + return 980243797; + case 223: + return 604001621; + case 225: + case 196: + return 559895893; case 150: + return 975983957; + case 149: case 151: - return 591760725; - case 118: - case 131: - case 128: - case 133: - case 121: - case 134: - case 104: - case 142: - case 145: - case 147: case 152: + return 975983957; + case 118: + case 132: + case 129: + case 134: + case 121: + case 135: + case 104: + case 143: + case 146: + case 148: case 153: case 154: - case 223: - case 224: + case 155: + case 226: + case 227: return -3; - case 172: - return 539110741; + case 175: + return 554784085; default: - return 536874325; + return 536892757; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -20210,7 +20937,10 @@ var ts; getAmbientModules: getAmbientModules, getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter + isOptionalParameter: isOptionalParameter, + tryFindAmbientModuleWithoutAugmentations: function (moduleName) { + return tryFindAmbientModule(moduleName, false); + } }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -20224,9 +20954,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 524288, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 524288, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -20236,11 +20966,15 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + emptyTypeLiteralSymbol.members = ts.createMap(); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - anyFunctionType.flags |= 2097152; + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -20328,6 +21062,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -20348,6 +21084,21 @@ var ts; builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); return checker; + function getJsxNamespace() { + if (_jsxNamespace === undefined) { + _jsxNamespace = "React"; + if (compilerOptions.jsxFactory) { + _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + if (_jsxFactoryEntity) { + _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text; + } + } + else if (compilerOptions.reactNamespace) { + _jsxNamespace = compilerOptions.reactNamespace; + } + } + return _jsxNamespace; + } function getEmitResolver(sourceFile, cancellationToken) { getDiagnostics(sourceFile, cancellationToken); return emitResolver; @@ -20428,7 +21179,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 229 && source.valueDeclaration.kind !== 229))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20484,7 +21235,7 @@ var ts; var moduleNotFoundError = !ts.isInAmbientContext(moduleName.parent.parent) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; - var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError); + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true); if (!mainModule) { return; } @@ -20525,7 +21276,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 260 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -20569,7 +21320,7 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 222 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -20577,17 +21328,17 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 204: + case 210: + case 212: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 211: + case 212: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20604,7 +21355,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 146 && + current.parent.kind === 147 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20627,18 +21378,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 277) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 143 || - lastLocation.kind === 142 + lastLocation.kind === 144 || + lastLocation.kind === 143 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 143 || + lastLocation.kind === 144 || (lastLocation === location.type && - result.valueDeclaration.kind === 143); + result.valueDeclaration.kind === 144); } } if (useResult) { @@ -20650,13 +21401,13 @@ var ts; } } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 229: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 260 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20666,7 +21417,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 242)) { break; } } @@ -20674,13 +21425,13 @@ var ts; break loop; } break; - case 225: + case 228: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 147: case 146: - case 145: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20690,9 +21441,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 225: + case 196: + case 226: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20700,7 +21451,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 196 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20708,28 +21459,28 @@ var ts; } } break; - case 141: + case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 223) { + if (ts.isClassLike(grandparent) || grandparent.kind === 226) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 181: + case 152: + case 224: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 183: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20742,8 +21493,8 @@ var ts; } } break; - case 144: - if (location.parent && location.parent.kind === 143) { + case 145: + if (location.parent && location.parent.kind === 144) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20785,7 +21536,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 229) { + if (decls && decls.length === 1 && decls[0].kind === 232) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20832,9 +21583,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 176: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 198: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20855,7 +21606,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 222), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20872,10 +21623,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 234) { node = node.parent; } return node; @@ -20885,7 +21636,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 241) { + if (node.moduleReference.kind === 244) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20946,28 +21697,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_19 = specifier.propertyName || specifier.name; + if (name_19.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_19.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_19.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_19.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_19.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_19, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_19)); } return symbol; } @@ -20989,19 +21740,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: - return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); case 233: - return getTargetOfNamespaceImport(node); + return getTargetOfImportEqualsDeclaration(node); case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node); case 236: + return getTargetOfNamespaceImport(node); + case 238: + return getTargetOfImportSpecifier(node); + case 242: + return getTargetOfExportSpecifier(node); + case 239: return getTargetOfExportAssignment(node); - case 229: + case 232: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21045,10 +21796,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 239) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 242) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21060,11 +21811,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 140) { + if (entityName.kind === 70 || entityName.parent.kind === 141) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 230); + ts.Debug.assert(entityName.parent.kind === 233); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21083,9 +21834,9 @@ var ts; return undefined; } } - else if (name.kind === 140 || name.kind === 173) { - var left = name.kind === 140 ? name.left : name.expression; - var right = name.kind === 140 ? name.right : name.name; + else if (name.kind === 141 || name.kind === 176) { + var left = name.kind === 141 ? name.left : name.expression; + var right = name.kind === 141 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -21110,27 +21861,28 @@ var ts; function resolveExternalModuleName(location, moduleReferenceExpression) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); } - function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral); + return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); } - function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode) { + function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } var moduleName = ts.escapeIdentifier(moduleReference); if (moduleName === undefined) { return; } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); - if (symbol) { - return getMergedSymbol(symbol); - } + var ambientModule = tryFindAmbientModule(moduleName, true); + if (ambientModule) { + return ambientModule; } + var isRelative = ts.isExternalModuleNameRelative(moduleName); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); + var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return getMergedSymbol(sourceFile.symbol); @@ -21146,14 +21898,30 @@ var ts; return getMergedSymbol(pattern.symbol); } } + if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (isForAugmentation) { + ts.Debug.assert(!!moduleNotFoundError); + var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; + error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + } + else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + } + return undefined; + } if (moduleNotFoundError) { - var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); - if (tsExtension) { - var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + if (resolutionDiagnostic) { + error(errorNode, resolutionDiagnostic, moduleName, resolvedModule.resolvedFileName); } else { - error(errorNode, moduleNotFoundError, moduleName); + var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } } return undefined; @@ -21268,7 +22036,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 149 && ts.nodeIsPresent(member.body)) { + if (member.kind === 150 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21339,11 +22107,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 229: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21376,7 +22144,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21407,7 +22175,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21421,10 +22189,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 146: - case 148: - case 150: + case 147: + case 149: case 151: + case 152: continue; default: return false; @@ -21480,7 +22248,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 260 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -21514,11 +22282,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 140 || entityName.kind === 173 || - entityName.parent.kind === 230) { + else if (entityName.kind === 141 || entityName.kind === 176 || + entityName.parent.kind === 233) { meaning = 1920; } else { @@ -21610,10 +22378,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 165) { + while (node.kind === 166) { node = node.parent; } - if (node.kind === 224) { + if (node.kind === 227) { return getSymbolOfNode(node); } } @@ -21621,7 +22389,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 230 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21635,10 +22403,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 196: return "(Anonymous class)"; - case 180: - case 181: + case 183: + case 184: return "(Anonymous function)"; } } @@ -21690,9 +22458,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21744,9 +22512,7 @@ var ts; else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && - (getObjectFlags(type) & 16 && !type.target || type.flags & 196608) && - type.aliasSymbol && + else if (!(flags & 512) && (getObjectFlags(type) & 16 || type.flags & 196608) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -21760,6 +22526,17 @@ var ts; else if (type.flags & 96) { writer.writeStringLiteral(literalTypeToString(type)); } + else if (type.flags & 262144) { + writer.writeKeyword("keyof"); + writeSpace(writer); + writeType(type.type, 64); + } + else if (type.flags & 524288) { + writeType(type.objectType, 64); + writePunctuation(writer, 20); + writeType(type.indexType, 0); + writePunctuation(writer, 21); + } else { writePunctuation(writer, 16); writeSpace(writer); @@ -21816,12 +22593,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21855,7 +22632,7 @@ var ts; } else if (ts.contains(symbolStack, symbol)) { var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias && !type.target) { + if (typeAlias) { buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { @@ -21880,7 +22657,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 227; + return declaration.parent.kind === 260 || declaration.parent.kind === 230; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21896,7 +22673,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -21914,7 +22691,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -21970,6 +22747,12 @@ var ts; writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, 17); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); @@ -21982,8 +22765,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 133); - writeIndexSignature(resolved.numberIndexInfo, 131); + writeIndexSignature(resolved.stringIndexInfo, 134); + writeIndexSignature(resolved.numberIndexInfo, 132); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -22006,9 +22789,6 @@ var ts; writer.writeLine(); } } - writer.decreaseIndent(); - writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -22046,12 +22826,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -22065,7 +22845,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 173); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -22193,63 +22973,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 173: return isDeclarationVisible(node.parent.parent); - case 219: + case 222: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: + case 229: case 225: - case 230: + case 226: + case 227: + case 224: + case 228: + case 233: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_9 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 233 && parent_9.kind !== 260 && ts.isInAmbientContext(parent_9))) { + return isGlobalSourceFile(parent_9); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_9); case 147: + case 146: + case 151: + case 152: + case 149: + case 148: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 149: - case 153: - case 152: + case 150: case 154: - case 143: - case 227: - case 157: + case 153: + case 155: + case 144: + case 230: case 158: - case 160: - case 156: + case 159: case 161: + case 157: case 162: case 163: case 164: case 165: + case 166: return isDeclarationVisible(node.parent); - case 232: - case 233: case 235: - return false; - case 142: - case 256: - case 229: - return true; case 236: + case 238: + return false; + case 143: + case 260: + case 232: + return true; + case 239: return false; default: return false; @@ -22258,10 +23038,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 239) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 239) { + else if (node.parent.kind === 242) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22339,12 +23119,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: + case 222: + case 223: + case 238: + case 237: + case 236: case 235: - case 234: - case 233: - case 232: node = node.parent; break; default: @@ -22370,22 +23150,30 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70: - return name.text; - case 9: - case 8: - return name.text; - case 141: - if (ts.isStringOrNumericLiteral(name.expression.kind)) { - return name.expression.text; - } - } - return undefined; - } function isComputedNonLiteralName(name) { - return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression.kind); + } + function getRestType(source, properties, symbol) { + ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + var members = ts.createMap(); + var names = ts.createMap(); + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var name_20 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_20)] = true; + } + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + var inNamesToRemove = prop.name in names; + var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); + var isMethod = prop.flags & 8192; + var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); + if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + members[prop.name] = prop; + } + } + var stringIndexInfo = getIndexInfoOfType(source, 0); + var numberIndexInfo = getIndexInfoOfType(source, 1); + return createAnonymousType(symbol, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22400,26 +23188,45 @@ var ts; return parentType; } var type; - if (pattern.kind === 168) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { - return anyType; + if (pattern.kind === 171) { + if (declaration.dotDotDotToken) { + if (!(parentType.flags & 32768)) { + error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); + return unknownType; + } + var literalMembers = []; + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 197 && !element.dotDotDotToken) { + literalMembers.push(element.propertyName || element.name); + } + } + type = getRestType(parentType, literalMembers, declaration.symbol); } - if (declaration.initializer) { - getContextualType(declaration.initializer); - } - var text = getTextOfPropertyName(name_17); - type = getTypeOfPropertyOfType(parentType, text) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); - return unknownType; + else { + var name_21 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_21)) { + return anyType; + } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } + var text = ts.getTextOfPropertyName(name_21); + type = getTypeOfPropertyOfType(parentType, text) || + isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || + getIndexTypeOfType(parentType, 0); + if (!type) { + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_21)); + return unknownType; + } } } else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); - if (!declaration.dotDotDotToken) { + if (declaration.dotDotDotToken) { + type = createArrayType(elementType); + } + else { var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -22434,9 +23241,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -22456,15 +23260,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 219 && - declaration.parent.kind === 220 && - declaration.parent.parent.kind === 201) { + if (declaration.kind === 222 && + declaration.parent.kind === 223 && + declaration.parent.parent.kind === 204) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 143) { + else if (declaration.kind === 144) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22478,22 +23282,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 174 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 211) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 212) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22502,7 +23306,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + if (declaration.kind === 222 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22511,10 +23315,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var func = declaration.parent; - if (func.kind === 151 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); + if (func.kind === 152 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22540,7 +23344,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 257) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22565,11 +23369,11 @@ var ts; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { + if (isComputedNonLiteralName(name) || e.dotDotDotToken) { hasComputedProperties = true; return; } - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -22600,7 +23404,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 171 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22610,7 +23414,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 256) { return type; } return getWidenedType(type); @@ -22625,7 +23429,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 143 ? root.parent : root; + var memberDeclaration = root.kind === 144 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22638,25 +23442,25 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 239) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 284 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 188 || - declaration.kind === 173 && declaration.parent.kind === 188) { - if (declaration.flags & 1048576) { + if (declaration.kind === 191 || + declaration.kind === 176 && declaration.parent.kind === 191) { + if (declaration.flags & 2097152) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 191 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22682,7 +23486,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22702,9 +23506,9 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 150); - var setter = ts.getDeclarationOfKind(symbol, 151); - if (getter && getter.flags & 1048576) { + var getter = ts.getDeclarationOfKind(symbol, 151); + var setter = ts.getDeclarationOfKind(symbol, 152); + if (getter && getter.flags & 2097152) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -22744,7 +23548,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 150); + var getter_1 = ts.getDeclarationOfKind(symbol, 151); error(getter_1, 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)); } } @@ -22755,7 +23559,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22840,9 +23644,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 222 || node.kind === 193 || - node.kind === 221 || node.kind === 180 || - node.kind === 148 || node.kind === 181) { + if (node.kind === 225 || node.kind === 196 || + node.kind === 224 || node.kind === 183 || + node.kind === 149 || node.kind === 184) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22851,15 +23655,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 226); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 223 || node.kind === 222 || - node.kind === 193 || node.kind === 224) { + if (node.kind === 226 || node.kind === 225 || + node.kind === 196 || node.kind === 227) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22985,7 +23789,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 226 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -23014,7 +23818,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223) { + if (declaration.kind === 226) { if (declaration.flags & 64) { return false; } @@ -23065,7 +23869,7 @@ var ts; return unknownType; } var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 283); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -23076,7 +23880,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); + declaration = ts.getDeclarationOfKind(symbol, 227); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -23100,14 +23904,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8 || expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -23135,7 +23939,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -23173,7 +23977,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 142).constraint) { + if (!ts.getDeclarationOfKind(symbol, 143).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -23223,19 +24027,19 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 167: + case 129: + case 170: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -23244,7 +24048,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -23260,12 +24064,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 146: - case 145: - return isIndependentVariableLikeDeclaration(declaration); - case 148: case 147: + case 146: + return isIndependentVariableLikeDeclaration(declaration); case 149: + case 148: + case 150: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23331,8 +24135,8 @@ var ts; else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); + constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } @@ -23394,7 +24198,7 @@ var ts; var baseSig = baseSignatures_1[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23487,6 +24291,9 @@ var ts; function intersectIndexInfos(info1, info2) { return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); } + function unionSpreadIndexInfos(info1, info2) { + return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; @@ -23505,8 +24312,8 @@ var ts; var symbol = type.symbol; if (type.target) { var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); - var callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); - var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper); var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper); var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -23607,7 +24414,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 196608 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -23620,22 +24429,13 @@ var ts; return type.resolvedApparentType; } function getApparentType(type) { - if (type.flags & 16384) { - type = getApparentTypeOfTypeParameter(type); - } - if (type.flags & 34) { - type = globalStringType; - } - else if (type.flags & 340) { - type = globalNumberType; - } - else if (type.flags & 136) { - type = globalBooleanType; - } - else if (type.flags & 512) { - type = getGlobalESSymbolType(); - } - return type; + var t = type.flags & 16384 ? getApparentTypeOfTypeParameter(type) : type; + return t.flags & 34 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 262144 ? stringOrNumberType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -23776,7 +24576,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -23804,8 +24604,8 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 1048576) { - if (node.type && node.type.kind === 268) { + if (node.flags & 2097152) { + if (node.type && node.type.kind === 272) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -23814,11 +24614,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 272; } } } } + function tryFindAmbientModule(moduleName, withAugmentations) { + if (ts.isExternalModuleNameRelative(moduleName)) { + return undefined; + } + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; + } function isOptionalParameter(node) { if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) { return true; @@ -23872,7 +24679,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 170) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23884,10 +24691,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 150 || declaration.kind === 151) && + if ((declaration.kind === 151 || declaration.kind === 152) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 150 ? 151 : 150; + var otherKind = declaration.kind === 151 ? 152 : 151; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23899,14 +24706,14 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - var classType = declaration.kind === 149 ? + var classType = declaration.kind === 150 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 155 ? + var typePredicate = declaration.type && declaration.type.kind === 156 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -23923,14 +24730,14 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 151); + if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 152); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23944,20 +24751,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 269: + case 152: + case 183: + case 184: + case 273: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -24025,6 +24832,11 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); + var id = getTypeListId(typeArguments); + return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + } + function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { @@ -24037,7 +24849,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -24051,7 +24863,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 131 : 133; + var syntaxKind = kind === 1 ? 132 : 134; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -24078,7 +24890,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 142).constraint; + return ts.getDeclarationOfKind(type.symbol, 143).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -24111,7 +24923,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); } function getTypeListId(types) { var result = ""; @@ -24144,7 +24956,7 @@ var ts; result |= type.flags; } } - return result & 3670016; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -24212,11 +25024,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 271: return node.name; - case 195: + case 198: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -24240,7 +25052,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 271) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -24250,13 +25062,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 271) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 156 + var typeNameOrExpression = node.kind === 157 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -24285,9 +25097,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 222: - case 223: case 225: + case 226: + case 228: return declaration; } } @@ -24425,7 +25237,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 524288)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -24501,7 +25313,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 262144 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -24578,14 +25390,14 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var _loop_1 = function (i) { + var _loop_2 = function (i) { var type_1 = types[i]; if (type_1.flags & 65536) { return { value: getUnionType(ts.map(type_1.types, function (t) { return getIntersectionType(ts.replaceElement(types, i, t)); }), false, aliasSymbol, aliasTypeArguments) }; } }; for (var i = 0; i < types.length; i++) { - var state_2 = _loop_1(i); + var state_2 = _loop_2(i); if (typeof state_2 === "object") return state_2.value; } @@ -24615,25 +25427,215 @@ var ts; } return links.resolvedType; } + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return ts.startsWith(prop.name, "__@") ? neverType : getLiteralTypeForText(32, ts.unescapeIdentifier(prop.name)); + } + function getLiteralTypeFromPropertyNames(type) { + return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName)); + } + function getIndexType(type) { + return type.flags & 16384 ? getIndexTypeForTypeParameter(type) : + type.flags & 1 || getIndexInfoOfType(type, 0) ? stringOrNumberType : + getIndexInfoOfType(type, 1) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getLiteralTypeFromPropertyNames(type); + } + function getTypeFromTypeOperatorNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexType(getTypeFromTypeNodeNoAlias(node.type)); + } + return links.resolvedType; + } + function createIndexedAccessType(objectType, indexType) { + var type = createType(524288); + type.objectType = objectType; + type.indexType = indexType; + return type; + } + function getIndexedAccessTypeForTypeParameter(objectType, indexType) { + var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); + return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); + } + function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { + var accessExpression = accessNode && accessNode.kind === 177 ? accessNode : undefined; + var propName = indexType.flags & (32 | 64 | 256) ? + indexType.text : + accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? + ts.getPropertyNameForKnownSymbolName(accessExpression.argumentExpression.name.text) : + undefined; + if (propName) { + var prop = getPropertyOfType(objectType, propName); + if (prop) { + if (accessExpression) { + if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { + error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); + return unknownType; + } + if (cacheSymbol) { + getNodeLinks(accessNode).resolvedSymbol = prop; + } + } + return getTypeOfSymbol(prop); + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512)) { + if (isTypeAny(objectType)) { + return anyType; + } + var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340) && getIndexInfoOfType(objectType, 1) || + getIndexInfoOfType(objectType, 0) || + undefined; + if (indexInfo) { + if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + return unknownType; + } + return indexInfo.type; + } + if (accessExpression && !isConstEnumObjectType(objectType)) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (getIndexTypeOfType(objectType, 1)) { + error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } + } + return anyType; + } + } + if (accessNode) { + var indexNode = accessNode.kind === 177 ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (32 | 64)) { + error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); + } + else if (indexType.flags & (2 | 4)) { + error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); + } + else { + error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); + } + } + return unknownType; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + if (indexType.flags & 16384) { + if (!isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + if (accessNode) { + error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); + } + return unknownType; + } + return getIndexedAccessTypeForTypeParameter(objectType, indexType); + } + var apparentType = getApparentType(objectType); + if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + var propTypes = []; + for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, false); + if (propType === unknownType) { + return unknownType; + } + propTypes.push(propType); + } + return getUnionType(propTypes); + } + return getPropertyTypeForIndexType(apparentType, indexType, accessNode, true); + } + function getTypeFromIndexedAccessTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexedAccessType(getTypeFromTypeNodeNoAlias(node.objectType), getTypeFromTypeNodeNoAlias(node.indexType), node); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(16, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; - links.resolvedType = type; + if (ts.isEmpty(node.symbol.members) && !aliasSymbol && !aliasTypeArguments) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = type; + } } return links.resolvedType; } + function getSpreadType(left, right, isFromObjectLiteral) { + ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); + if (left.flags & 1 || right.flags & 1) { + return anyType; + } + var members = ts.createMap(); + var skippedPrivateMembers = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + if (left === emptyObjectType) { + stringIndexInfo = getIndexInfoOfType(right, 0); + numberIndexInfo = getIndexInfoOfType(right, 1); + } + else { + stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0)); + numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1)); + } + for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { + var rightProp = _a[_i]; + var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; + var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { + skippedPrivateMembers[rightProp.name] = true; + } + else if (isOwnProperty && !isSetterWithoutGetter) { + members[rightProp.name] = rightProp; + } + } + for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { + var leftProp = _c[_b]; + if (leftProp.flags & 65536 && !(leftProp.flags & 32768) + || leftProp.name in skippedPrivateMembers) { + continue; + } + if (leftProp.name in members) { + var rightProp = members[leftProp.name]; + var rightType = getTypeOfSymbol(rightProp); + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); + var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var result = createSymbol(flags, leftProp.name); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); + result.leftSpread = leftProp; + result.rightSpread = rightProp; + result.declarations = declarations; + result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); + members[leftProp.name] = result; + } + } + else { + members[leftProp.name] = leftProp; + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 && !(type.flags & 262144)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 262144, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -24642,7 +25644,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 262144 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -24674,9 +25676,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 226)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24696,79 +25698,83 @@ var ts; function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { case 118: - case 258: - case 259: + case 262: + case 263: return anyType; - case 133: + case 134: return stringType; - case 131: + case 132: return numberType; case 121: return booleanType; - case 134: + case 135: return esSymbolType; case 104: return voidType; - case 136: + case 137: return undefinedType; case 94: return nullType; - case 128: + case 129: return neverType; - case 283: + case 287: return nullType; - case 284: + case 288: return undefinedType; - case 285: + case 289: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 170: return getTypeFromLiteralTypeNode(node); - case 282: + case 286: return getTypeFromLiteralTypeNode(node.literal); - case 156: - case 267: - return getTypeFromTypeReference(node); - case 155: - return booleanType; - case 195: - return getTypeFromTypeReference(node); - case 159: - return getTypeFromTypeQueryNode(node); - case 161: - case 260: - return getTypeFromArrayTypeNode(node); - case 162: - return getTypeFromTupleTypeNode(node); - case 163: - case 261: - return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 165: - case 263: - case 264: - case 271: - case 272: - case 268: - return getTypeFromTypeNode(node.type); - case 265: - return getTypeFromTypeNode(node.literal); case 157: - case 158: + case 271: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 198: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 264: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 265: + return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 166: + case 267: + case 268: + case 275: + case 276: + case 272: + return getTypeFromTypeNode(node.type); case 269: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 285: + case 273: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 266: return getTypeFromJSDocTupleType(node); - case 270: + case 274: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24785,6 +25791,12 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -24807,7 +25819,6 @@ var ts; count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; - mapper.targetTypes = targets; return mapper; } function createTypeEraser(sources) { @@ -24910,32 +25921,35 @@ var ts; result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); mapper.instantiations[type.id] = result; return result; } function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { + if (!(symbol.declarations && symbol.declarations.length)) { + return false; + } var mappedTypes = mapper.mappedTypes; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 222: - case 193: - case 223: - case 224: + case 152: + case 183: + case 184: + case 225: + case 196: + case 226: + case 227: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24945,15 +25959,15 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 226) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 229: + case 260: return false; } node = node.parent; @@ -24973,14 +25987,20 @@ var ts; instantiateAnonymousType(type, mapper) : type; } if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (type.flags & 131072) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } } return type; @@ -24989,27 +26009,27 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 180: - case 181: + case 183: + case 184: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 175: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 174: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 192: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 191: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 256: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 182: return isContextSensitive(node.expression); } return false; @@ -25021,7 +26041,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 184) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -25270,10 +26290,10 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { @@ -25286,7 +26306,7 @@ var ts; return related === 1; } } - if (source.flags & 245760 || target.flags & 245760) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -25323,9 +26343,15 @@ var ts; targetType = typeToString(target, undefined, 128); } if (!message) { - message = relation === comparableRelation ? - ts.Diagnostics.Type_0_is_not_comparable_to_type_1 : - ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + if (relation === comparableRelation) { + message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1; + } + else if (sourceType === targetType) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; + } + else { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + } } reportError(message, sourceType, targetType); } @@ -25341,10 +26367,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -25354,7 +26380,7 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (getObjectFlags(source) & 64 && source.flags & 262144) { + if (getObjectFlags(source) & 64 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -25392,6 +26418,22 @@ var ts; return result; } } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + } + } + else if (target.flags & 262144) { + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } if (source.flags & 16384) { var constraint = getConstraintOfTypeParameter(source); if (!constraint || constraint.flags & 1) { @@ -25656,8 +26698,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 64); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var targetProp = properties_3[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -26094,8 +27136,8 @@ var ts; type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 262144 ? stringType : - type.flags & 64 && type.flags & 262144 ? numberType : + return type.flags & 32 && type.flags & 1048576 ? stringType : + type.flags & 64 && type.flags & 1048576 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : @@ -26174,7 +27216,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(getObjectFlags(type) & 64 && type.flags & 262144)) { + if (!(getObjectFlags(type) & 64 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -26184,7 +27226,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~262144; + regularNew.flags = resolved.flags & ~1048576; regularNew.objectFlags |= 64; type.regularType = regularNew; return regularNew; @@ -26202,7 +27244,7 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 1572864) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } @@ -26240,7 +27282,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 524288) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -26254,25 +27296,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 147: case 146: - case 145: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 143: + case 144: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 170: + case 173: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 224: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 183: + case 184: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -26285,7 +27327,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -26392,7 +27434,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 2097152) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -26479,8 +27521,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -26554,7 +27596,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 8190); + return constraint && maybeTypeOfKind(constraint, 8190 | 262144); } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; @@ -26607,10 +27649,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 159: + case 160: return true; case 70: - case 140: + case 141: node = node.parent; continue; default: @@ -26627,7 +27669,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 176) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26638,7 +27680,7 @@ var ts; case 70: case 98: return node; - case 173: + case 176: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -26647,19 +27689,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 222 || target.kind === 173) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 176: + return target.kind === 176 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 176) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26668,7 +27710,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 176 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26676,7 +27718,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 176) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26706,7 +27748,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 176 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26817,7 +27859,7 @@ var ts; return type; } function getTypeOfDestructuredProperty(type, name) { - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || @@ -26828,19 +27870,19 @@ var ts; checkIteratedTypeOrElementType(type, undefined, false) || unknownType; } - function getTypeOfDestructuredSpreadElement(type) { + function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 171 || node.parent.kind === 253 ? + return node.parent.kind === 174 || node.parent.kind === 256 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } - function getAssignedTypeOfSpreadElement(node) { - return getTypeOfDestructuredSpreadElement(getAssignedType(node.parent)); + function getAssignedTypeOfSpreadExpression(node) { + return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent)); } function getAssignedTypeOfPropertyAssignment(node) { return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name); @@ -26851,21 +27893,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 211: return stringType; - case 209: + case 212: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: + case 191: return getAssignedTypeOfBinaryExpression(parent); - case 182: + case 185: return undefinedType; - case 171: + case 174: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + case 195: + return getAssignedTypeOfSpreadExpression(parent); + case 256: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 257: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26873,11 +27915,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 171 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : - getTypeOfDestructuredSpreadElement(parentType); + getTypeOfDestructuredSpreadExpression(parentType); return getTypeWithDefault(type, node.initializer); } function getTypeOfInitializer(node) { @@ -26888,35 +27930,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 211) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 212) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 222 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 222 || node.kind === 173 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 222 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 173 && node.parent.kind === 191 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 182: return getReferenceCandidate(node.expression); - case 188: + case 191: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -26928,13 +27970,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 179 || - parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 182 || + parent.kind === 191 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 191 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 252) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27052,11 +28094,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || - parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 174 && + var isLengthPushOrUnshift = parent.kind === 176 && (parent.name.text === "length" || + parent.parent.kind === 178 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 177 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 191 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -27065,7 +28107,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 246783)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -27075,7 +28117,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 128 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 200 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -27120,7 +28162,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 173) { + if (container && container !== flowContainer && reference.kind !== 176) { flow = container.flowNode; continue; } @@ -27140,7 +28182,7 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 186 || node.parent.kind === 187) { + if (ts.getAssignmentTargetKind(node) === 2) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -27163,7 +28205,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 178 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -27171,7 +28213,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 128) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 178) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -27289,7 +28331,7 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && + return expr.kind === 176 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -27323,10 +28365,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 === 183 && right_1.kind === 9) { + if (left_1.kind === 186 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 183 && left_1.kind === 9) { + if (right_1.kind === 186 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -27503,10 +28545,10 @@ var ts; } } else { - var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { + var invokedExpression = ts.skipParentheses(callExpression.expression); + if (invokedExpression.kind === 177 || invokedExpression.kind === 176) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -27521,15 +28563,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: + case 178: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179: + case 182: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 191: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 189: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -27552,19 +28594,13 @@ var ts; } return getTypeOfSymbol(symbol); } - function skipParenthesizedNodes(expression) { - while (expression.kind === 179) { - expression = expression.expression; - } - return expression; - } function getControlFlowContainer(node) { while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 227 || - node.kind === 256 || - node.kind === 146) { + node.kind === 230 || + node.kind === 260 || + node.kind === 147) { return node; } } @@ -27595,7 +28631,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { symbol.isAssigned = true; } } @@ -27609,19 +28645,23 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return unknownType; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 181) { + if (container.kind === 184) { 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.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 262144) { + if (node.flags & 524288) { getNodeLinks(container).flags |= 8192; } + return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -27630,7 +28670,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 225 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27642,11 +28682,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 196) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 146 && ts.hasModifier(container, 32)) { + if (container.kind === 147 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27661,15 +28701,26 @@ var ts; checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; - if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (!(localOrExportSymbol.flags & 3)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + return unknownType; + } + if (isReadonlySymbol(localOrExportSymbol)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); + return unknownType; + } + } + if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 143; + var isParameter = ts.getRootDeclaration(declaration).kind === 144; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || - flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 183 || + flowContainer.kind === 184 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -27690,7 +28741,7 @@ var ts; error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } - return flowType; + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { var current = node; @@ -27705,7 +28756,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 255) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27723,8 +28774,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 210 && + ts.getAncestor(symbol.valueDeclaration, 223).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27736,14 +28787,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 182) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 186 || current.parent.kind === 187)) { + else if ((current.parent.kind === 189 || current.parent.kind === 190)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27762,7 +28813,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 146 || container.kind === 149) { + if (container.kind === 147 || container.kind === 150) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27796,7 +28847,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 149) { + if (container.kind === 150) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27806,29 +28857,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 184) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 229: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 228: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 149: + case 150: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 147: case 146: - case 145: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 141: + case 142: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27837,7 +28888,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 183 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27872,27 +28923,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 269) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 273) { var jsDocFunctionType = typeTag.typeExpression.type; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 272) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 276) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 143) { + if (n.kind === 144) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 178 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 184) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27901,16 +28952,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 141) { + while (current && current !== container && current.kind !== 142) { current = current.parent; } - if (current && current.kind === 141) { + if (current && current.kind === 142) { 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 === 172)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 175)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27925,7 +28976,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 148 && ts.getModifierFlags(container) & 256) { + if (container.kind === 149 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27936,7 +28987,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 175) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27954,7 +29005,7 @@ var ts; } return unknownType; } - if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27966,24 +29017,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 149; + return container.kind === 150; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 172) { + if (ts.isClassLike(container.parent) || container.parent.kind === 175) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || - container.kind === 151; + return container.kind === 149 || + container.kind === 148 || + container.kind === 151 || + container.kind === 152; } else { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || + return container.kind === 149 || + container.kind === 148 || container.kind === 151 || + container.kind === 152 || + container.kind === 147 || container.kind === 146 || - container.kind === 145 || - container.kind === 149; + container.kind === 150; } } } @@ -27991,7 +29042,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 184) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -28047,7 +29098,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -28058,11 +29109,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_22 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_22)) { + var text = ts.getTextOfPropertyName(name_22); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -28099,7 +29150,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 143 && node.parent.initializer === node) { + if (node.parent.kind === 144 && node.parent.initializer === node) { return true; } node = node.parent; @@ -28108,8 +29159,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 149 || - functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { + functionDecl.kind === 150 || + functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -28128,7 +29179,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 180) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -28236,13 +29287,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 249) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 250) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -28260,41 +29311,41 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 170: + case 173: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 184: + case 215: return getContextualTypeForReturnExpression(node); - case 191: + case 194: return getContextualTypeForYieldOperand(parent); - case 175: - case 176: - return getContextualTypeForArgument(parent, node); case 178: - case 196: - return getTypeFromTypeNode(parent.type); - case 188: - return getContextualTypeForBinaryOperand(node); - case 253: - case 254: - return getContextualTypeForObjectLiteralElement(parent); - case 171: - return getContextualTypeForElementExpression(node); - case 189: - return getContextualTypeForConditionalOperand(node); - case 198: - ts.Debug.assert(parent.parent.kind === 190); - return getContextualTypeForSubstitutionExpression(parent.parent, node); case 179: + return getContextualTypeForArgument(parent, node); + case 181: + case 199: + return getTypeFromTypeNode(parent.type); + case 191: + return getContextualTypeForBinaryOperand(node); + case 256: + case 257: + return getContextualTypeForObjectLiteralElement(parent); + case 174: + return getContextualTypeForElementExpression(node); + case 192: + return getContextualTypeForConditionalOperand(node); + case 201: + ts.Debug.assert(parent.parent.kind === 193); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 182: return getContextualType(parent); - case 248: + case 251: return getContextualType(parent); - case 246: - case 247: + case 249: + case 250: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -28323,7 +29374,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 183 || node.kind === 184; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -28336,7 +29387,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -28372,13 +29423,13 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper.context; } - function checkSpreadElementExpression(node, contextualMapper) { + function checkSpreadExpression(node, contextualMapper) { var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 170 && !!node.initializer) || - (node.kind === 188 && node.operatorToken.kind === 57); + return (node.kind === 173 && !!node.initializer) || + (node.kind === 191 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -28387,7 +29438,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 192) { + if (inDestructuringPattern && e.kind === 195) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -28399,7 +29450,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 195; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -28410,7 +29461,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { + if (pattern && (pattern.kind === 172 || pattern.kind === 174)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -28418,7 +29469,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 197) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -28435,7 +29486,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -28477,9 +29528,11 @@ var ts; checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); var propertiesArray = []; + var spread = emptyObjectType; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); + (contextualType.pattern.kind === 171 || contextualType.pattern.kind === 175); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -28487,25 +29540,25 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 253 || - memberDecl.kind === 254 || + if (memberDecl.kind === 256 || + memberDecl.kind === 257 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 256) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 148) { + else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 254); + ts.Debug.assert(memberDecl.kind === 257); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 253 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 254 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 256 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 257 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -28531,8 +29584,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 258) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + propertiesArray = []; + propertiesTable = ts.createMap(); + hasComputedStringProperty = false; + hasComputedNumberProperty = false; + typeFlags = 0; + } + var type = checkExpression(memberDecl.expression); + if (!(type.flags & (32768 | 1))) { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return unknownType; + } + spread = getSpreadType(spread, type, false); + continue; + } else { - ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); + ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28560,19 +29630,33 @@ var ts; } } } - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 262144; - result.flags |= 1048576 | freshObjectLiteralFlag | (typeFlags & 3670016); - result.objectFlags |= 64; - if (patternWithComputedProperties) { - result.objectFlags |= 256; + if (spread !== emptyObjectType) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + } + spread.flags |= propagatedFlags; + spread.symbol = node.symbol; + return spread; } - if (inDestructuringPattern) { - result.pattern = node; + return createObjectLiteralType(); + function createObjectLiteralType() { + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + result.objectFlags |= 64; + if (patternWithComputedProperties) { + result.objectFlags |= 256; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -28589,13 +29673,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 251: checkJsxExpression(child); break; - case 242: + case 245: checkJsxElement(child); break; - case 243: + case 246: checkJsxSelfClosingElement(child); break; } @@ -28606,7 +29690,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 176 || tagName.kind === 98) { return false; } else { @@ -28622,7 +29706,7 @@ var ts; var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); + var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); if (attributeType) { correspondingPropType = attributeType; } @@ -28875,7 +29959,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); var reactRefErr = compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; + var reactNamespace = getJsxNamespace(); var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); if (reactSym) { reactSym.isReferenced = true; @@ -28887,11 +29971,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 246) { + if (node.attributes[i].kind === 249) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 250); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -28917,7 +30001,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 146; + return s.valueDeclaration ? s.valueDeclaration.kind : 147; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28928,11 +30012,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 173 || node.kind === 219 ? + var errorNode = node.kind === 176 || node.kind === 222 ? node.name : node.right; if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28995,6 +30079,33 @@ var ts; function checkQualifiedName(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } + function reportNonexistentProperty(propNode, containingType) { + var errorInfo; + if (containingType.flags & 65536 && !(containingType.flags & 8190)) { + for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { + var subtype = _a[_i]; + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + function markPropertyAsReferenced(prop) { + if (prop && + noUnusedIdentifiers && + (prop.flags & 106500) && + prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + if (prop.flags & 16777216) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -29011,44 +30122,29 @@ var ts; } return unknownType; } - if (noUnusedIdentifiers && - (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } + markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 173 || ts.isAssignmentTarget(node) || + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { + error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text); + return unknownType; + } + } + if (node.kind !== 176 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 65536 && !(containingType.flags & 8190)) { - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } + var flowType = getFlowTypeOfReference(node, propType, true, undefined); + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 173 + var left = node.kind === 176 ? node.expression : node.left; var type = checkExpression(left); @@ -29062,7 +30158,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 223) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29077,14 +30173,14 @@ var ts; return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0); } function isForInVariableForNumericPropertyNames(expr) { - var e = skipParenthesizedNodes(expr); + var e = ts.skipParentheses(expr); if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 208 && + if (node.kind === 211 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -29098,9 +30194,11 @@ var ts; return false; } function checkIndexedAccess(node) { - if (!node.argumentExpression) { + var objectType = checkNonNullExpression(node.expression); + var indexExpression = node.argumentExpression; + if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 176 && node.parent.expression === node) { + if (node.parent.kind === 179 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -29110,71 +30208,17 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } + return unknownType; } - var objectType = getApparentType(checkNonNullExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); if (objectType === unknownType || objectType === silentNeverType) { return objectType; } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { + error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - var allowedNullableFlags = strictNullChecks ? 0 : 6144; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512 | allowedNullableFlags)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexInfo = getIndexInfoOfType(objectType, 1); - if (numberIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; - return numberIndexInfo.type; - } - } - var stringIndexInfo = getIndexInfoOfType(objectType, 0); - if (stringIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; - return stringIndexInfo.type; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, getIndexTypeOfType(objectType, 1) ? - ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number : - ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; + return getIndexedAccessType(objectType, indexType, node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -29207,10 +30251,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 180) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -29232,19 +30276,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_11 = signature.declaration && signature.declaration.parent; + var parent_10 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_10 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_10; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_10; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29261,7 +30305,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 192) { + if (arg && arg.kind === 195) { return i; } } @@ -29274,11 +30318,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 180) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 193) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -29290,7 +30334,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 144) { + else if (node.kind === 145) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -29298,7 +30342,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 179); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -29357,7 +30401,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29404,7 +30448,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 176) { + if (thisType && thisType !== voidType && node.kind !== 179) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -29417,7 +30461,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29432,28 +30476,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 178) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 176) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 177) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 180) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 193) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -29462,21 +30506,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 144) { + if (node.kind === 145) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return 1; - case 146: + case 147: return 2; - case 148: - case 150: + case 149: case 151: + case 152: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 143: + case 144: return 3; } } @@ -29485,48 +30529,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { return anyType; } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 141: + case 142: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29543,20 +30587,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { return numberType; } - if (node.kind === 146) { + if (node.kind === 147) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29577,26 +30621,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 144) { + if (node.kind === 145) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 144 || - (argIndex === 0 && node.kind === 177)) { + if (node.kind === 145 || + (argIndex === 0 && node.kind === 180)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 144) { + if (node.kind === 145) { return node.expression; } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return node.template; } else { @@ -29604,8 +30648,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 180; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -29635,7 +30679,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 178 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29903,16 +30947,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 146: + case 147: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 148: - case 150: + case 149: case 151: + case 152: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29939,13 +30983,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 178: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 179: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 180: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29977,12 +31021,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 179) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 149 && - declaration.kind !== 153 && - declaration.kind !== 158 && + declaration.kind !== 150 && + declaration.kind !== 154 && + declaration.kind !== 159 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -30013,9 +31057,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 221 + ? 224 : resolvedRequire.flags & 3 - ? 219 + ? 222 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30108,8 +31152,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 168 || - parameter.valueDeclaration.name.kind === 169)) { + (parameter.valueDeclaration.name.kind === 171 || + parameter.valueDeclaration.name.kind === 172)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -30136,7 +31180,7 @@ var ts; function createPromiseReturnType(func, promisedType) { var promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } return promiseType; @@ -30148,7 +31192,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 203) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -30227,7 +31271,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 217 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30256,7 +31300,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 183 || func.kind === 184)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -30273,7 +31317,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 203 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30300,9 +31344,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 180) { + if (!hasGrammarError && node.kind === 183) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -30336,14 +31380,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 148) { + if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -30353,7 +31397,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 203) { checkSourceElement(node.body); } else { @@ -30388,10 +31432,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 176 || expr.kind === 177) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 149)) + if (!(func && func.kind === 150)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -30400,44 +31444,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 176 || expr.kind === 177) { + var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 233; + return declaration && declaration.kind === 236; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { - var node = skipParenthesizedNodes(expr); - if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { + function checkReferenceExpression(expr, invalidReferenceMessage) { + var node = ts.skipParentheses(expr); + if (node.kind !== 70 && node.kind !== 176 && node.kind !== 177) { error(expr, invalidReferenceMessage); return false; } - var links = getNodeLinks(node); - var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 70 && !(symbol.flags & 3)) { - error(expr, invalidReferenceMessage); - return false; - } - if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { - error(expr, constantVariableMessage); - return false; - } - } - } - else if (node.kind === 174) { - if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { - error(expr, constantVariableMessage); - return false; - } - } return true; } function checkDeleteExpression(node) { @@ -30454,7 +31478,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 262144)) { + if (!(node.flags & 524288)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -30489,7 +31513,7 @@ var ts; case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -30502,7 +31526,7 @@ var ts; } var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -30578,29 +31602,29 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var p = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var p = properties_5[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { - if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 141) { - checkComputedPropertyName(name_20); + if (property.kind === 256 || property.kind === 257) { + var name_23 = property.name; + if (name_23.kind === 142) { + checkComputedPropertyName(name_23); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_23)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name_23); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 254) { + if (property.kind === 257) { return checkDestructuringAssignment(property, type); } else { @@ -30608,10 +31632,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); } } - else { + else if (property.kind !== 258) { error(property, ts.Diagnostics.Property_assignment_expected); } } @@ -30626,8 +31650,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 194) { - if (element.kind !== 192) { + if (element.kind !== 197) { + if (element.kind !== 195) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30649,11 +31673,11 @@ var ts; } else { if (elementIndex < elements.length - 1) { - error(element, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { var restExpression = element.expression; - if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 191 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30666,7 +31690,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 257) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -30680,21 +31704,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 191 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 175) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 174) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { + if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -30705,35 +31729,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 180: + case 193: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: + case 137: case 183: - case 197: - case 243: - case 242: + case 196: + case 184: + case 174: + case 175: + case 186: + case 200: + case 246: + case 245: return true; - case 189: + case 192: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 191: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 189: + case 190: switch (node.operator) { case 50: case 36: @@ -30742,9 +31766,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 187: + case 181: + case 199: default: return false; } @@ -30764,7 +31788,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 172 || left.kind === 171)) { + if (operator === 57 && (left.kind === 175 || left.kind === 174)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30921,8 +31945,7 @@ var ts; } function checkAssignmentOperator(valueType) { if (produceDiagnostics && operator >= 57 && operator <= 69) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); - if (ok) { + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } } @@ -30948,7 +31971,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 65536) || isYieldExpressionInClass(node)) { + if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -31022,8 +32045,8 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = skipParenthesizedNodes(node); - return node.kind === 178 || node.kind === 196; + node = ts.skipParentheses(node); + return node.kind === 181 || node.kind === 199; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -31049,14 +32072,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -31079,7 +32102,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -31087,9 +32110,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 173 && node.parent.expression === node) || - (node.parent.kind === 174 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 176 && node.parent.expression === node) || + (node.parent.kind === 177 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); 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); } @@ -31111,66 +32134,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 193: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 171: - return checkArrayLiteral(node, contextualMapper); - case 172: - return checkObjectLiteral(node, contextualMapper); - case 173: - return checkPropertyAccessExpression(node); case 174: - return checkIndexedAccess(node); + return checkArrayLiteral(node, contextualMapper); case 175: + return checkObjectLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkPropertyAccessExpression(node); case 177: - return checkTaggedTemplateExpression(node); - case 179: - return checkExpression(node.expression, contextualMapper); - case 193: - return checkClassExpression(node); - case 180: - case 181: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183: - return checkTypeOfExpression(node); + return checkIndexedAccess(node); case 178: - case 196: - return checkAssertion(node); - case 197: - return checkNonNullAssertion(node); + case 179: + return checkCallExpression(node); + case 180: + return checkTaggedTemplateExpression(node); case 182: - return checkDeleteExpression(node); + return checkExpression(node.expression, contextualMapper); + case 196: + return checkClassExpression(node); + case 183: case 184: - return checkVoidExpression(node); - case 185: - return checkAwaitExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 186: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 181: + case 199: + return checkAssertion(node); + case 200: + return checkNonNullAssertion(node); + case 185: + return checkDeleteExpression(node); case 187: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkAwaitExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkPrefixUnaryExpression(node); + case 190: + return checkPostfixUnaryExpression(node); case 191: + return checkBinaryExpression(node, contextualMapper); + case 192: + return checkConditionalExpression(node, contextualMapper); + case 195: + return checkSpreadExpression(node, contextualMapper); + case 197: + return undefinedWideningType; + case 194: return checkYieldExpression(node); - case 248: + case 251: return checkJsxExpression(node); - case 242: + case 245: return checkJsxElement(node); - case 243: + case 246: return checkJsxSelfClosingElement(node); - case 244: + case 247: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31191,7 +32214,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -31202,7 +32225,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 149 || func.kind === 153 || func.kind === 158) { + if (func.kind === 150 || func.kind === 154 || func.kind === 159) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -31214,9 +32237,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 148 || - node.kind === 221 || - node.kind === 180; + return node.kind === 149 || + node.kind === 224 || + node.kind === 183; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -31257,9 +32280,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_24 = _a[_i].name; + if (ts.isBindingPattern(name_24) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -31272,16 +32295,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 184: + case 153: + case 224: + case 183: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_11 = node.parent; + if (node === parent_11.type) { + return parent_11; } } } @@ -31291,27 +32314,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 && - name_22.text === predicateVariableName) { + var name_25 = element.name; + if (name_25.kind === 70 && + name_25.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 169 || - name_22.kind === 168) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_25.kind === 172 || + name_25.kind === 171) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_25, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 154) { + if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || - node.kind === 152 || node.kind === 149 || - node.kind === 153) { + else if (node.kind === 158 || node.kind === 224 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -31323,10 +32346,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 153: + case 154: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 152: + case 153: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -31357,7 +32380,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149) { + if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -31371,13 +32394,13 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 150: + case 151: addName(names, member.name, memberName, 1); break; - case 151: + case 152: addName(names, member.name, memberName, 2); break; - case 146: + case 147: addName(names, member.name, memberName, 3); break; } @@ -31403,7 +32426,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 145) { + if (member.kind == 146) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -31425,7 +32448,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 226) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31440,7 +32463,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 133: + case 134: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -31448,7 +32471,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -31507,12 +32530,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 180 && n.kind !== 221) { + else if (n.kind !== 183 && n.kind !== 224) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -31532,7 +32555,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31555,18 +32578,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 150) { + if (node.kind === 151) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 150 ? 151 : 150; + var otherKind = node.kind === 151 ? 152 : 151; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31580,11 +32603,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 150) { + if (node.kind === 151) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 172) { + if (node.parent.kind !== 175) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31665,14 +32688,17 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 223 && - n.parent.kind !== 222 && - n.parent.kind !== 193 && + if (n.parent.kind !== 226 && + n.parent.kind !== 225 && + n.parent.kind !== 196 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31749,7 +32775,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 148 || node.kind === 147) && + var reportError = (node.kind === 149 || node.kind === 148) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31782,11 +32808,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 226 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { + if (node.kind === 224 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31897,16 +32923,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: - return 2097152; case 226: + return 2097152; + case 229: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: case 225: + case 228: return 2097152 | 1048576; - case 230: + case 233: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31998,51 +33024,50 @@ var ts; } } } - function checkCorrectPromiseType(returnType, location, diagnostic, typeName) { - if (returnType === unknownType) { - return unknownType; - } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType === emptyGenericType - || globalPromiseType === getTargetType(returnType)) { - return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - error(location, diagnostic, typeName); - return unknownType; - } function checkAsyncFunctionReturnType(node) { + var returnType = getTypeFromTypeNode(node.type); if (languageVersion >= 2) { - var returnType = getTypeFromTypeNode(node.type); - return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - return unknownType; + else { + markTypeNodeAsReferenced(node.type); + if (returnType === unknownType) { + return unknownType; + } + var promiseConstructorName = ts.getEntityNameFromTypeNode(node.type); + if (promiseConstructorName === undefined) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); + return unknownType; + } + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; + if (promiseConstructorType === unknownType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { + return unknownType; + } + var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var collidingSymbol = getSymbol(node.locals, rootName.text, 107455); + if (collidingSymbol) { + error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, rootName.text, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } } - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - return unknownType; - } - var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - var typeName = promiseConstructor - ? symbolToString(promiseConstructor) - : typeToString(promiseType); - return checkCorrectPromiseType(promiseType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); - } - checkReturnTypeAnnotationAsExpression(node); - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, 107455); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseNameOrNamespaceRoot.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -32054,22 +33079,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 225: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 143: + case 144: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 146: + case 147: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 148: - case 150: + case 149: case 151: + case 152: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -32077,29 +33102,15 @@ var ts; } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } - function checkTypeNodeAsExpression(node) { - if (node && node.kind === 156) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 156 ? 793064 : 1920; - var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608) { - var aliasTarget = resolveAlias(rootSymbol); - if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - function checkTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkReturnTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkParameterTypeAnnotationsAsExpressions(node) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); + function markTypeNodeAsReferenced(node) { + var typeName = node && ts.getEntityNameFromTypeNode(node); + var rootName = typeName && getFirstIdentifier(typeName); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + if (rootSymbol + && rootSymbol.flags & 8388608 + && symbolIsValue(rootSymbol) + && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } function checkDecorators(node) { @@ -32114,21 +33125,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 225: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); + for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + markTypeNodeAsReferenced(parameter.type); + } } break; - case 148: - case 150: + case 149: case 151: - checkParameterTypeAnnotationsAsExpressions(node); - checkReturnTypeAnnotationAsExpression(node); + case 152: + for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + markTypeNodeAsReferenced(parameter.type); + } + markTypeNodeAsReferenced(node.type); break; - case 146: - case 143: - checkTypeAnnotationAsExpression(node); + case 147: + case 144: + markTypeNodeAsReferenced(node.type); break; } } @@ -32147,7 +33164,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 141) { + if (node.name && node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -32189,43 +33206,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 256: - case 226: + case 260: + case 229: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 225: + case 196: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 226: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 183: + case 224: + case 184: + case 149: case 151: + case 152: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 147: - case 152: + case 148: case 153: case 154: - case 157: + case 155: case 158: + case 159: checkUnusedTypeParameters(node); break; } @@ -32234,11 +33251,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { + if (node.parent.kind !== 226 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 143) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -32253,16 +33270,16 @@ var ts; } }; for (var key in node.locals) { - _loop_2(key); + _loop_3(key); } } } function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 219 && - (declaration.parent.parent.kind === 208 || - declaration.parent.parent.kind === 209)) { + if (declaration.kind === 222 && + (declaration.parent.parent.kind === 211 || + declaration.parent.parent.kind === 212)) { return; } } @@ -32279,12 +33296,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 || member.kind === 146) { + if (member.kind === 149 || member.kind === 147) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 149) { + else if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -32329,7 +33346,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 203) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32351,19 +33368,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 146 || - node.kind === 145 || + if (node.kind === 147 || + node.kind === 146 || + node.kind === 149 || node.kind === 148 || - node.kind === 147 || - node.kind === 150 || - node.kind === 151) { + node.kind === 151 || + node.kind === 152) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -32414,11 +33431,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32426,11 +33443,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { error(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)); } } @@ -32438,7 +33455,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 222 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -32448,25 +33465,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); - var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 223); + var container = varDeclList.parent.kind === 204 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 200 && ts.isFunctionLike(container.parent) || - container.kind === 227 || - container.kind === 226 || - container.kind === 256); + (container.kind === 203 && ts.isFunctionLike(container.parent) || + container.kind === 230 || + container.kind === 229 || + container.kind === 260); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name_26 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_26, name_26); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 143) { + if (ts.getRootDeclaration(node).kind !== 144) { return; } var func = ts.getContainingFunction(node); @@ -32475,7 +33492,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 176) { return visit(n.expression); } else if (n.kind === 70) { @@ -32489,7 +33506,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 143) { + if (symbol.valueDeclaration.kind === 144) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -32498,7 +33515,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 146 && + if (current.parent.kind === 147 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -32520,33 +33537,34 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 170) { - if (node.propertyName && node.propertyName.kind === 141) { + if (node.kind === 173) { + if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_13 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); - if (parent_13.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); + var parent_12 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_12); + var name_27 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_27)); + markPropertyAsReferenced(property); + if (parent_12.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -32555,7 +33573,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32573,9 +33591,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 146 && node.kind !== 145) { + if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 219 || node.kind === 170) { + if (node.kind === 222 || node.kind === 173) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32585,8 +33603,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 143 && right.kind === 219) || - (left.kind === 219 && right.kind === 143)) { + if ((left.kind === 144 && right.kind === 222) || + (left.kind === 222 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32613,7 +33631,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 172) { + if (node.modifiers && node.parent.kind === 175) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32632,7 +33650,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 205) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32649,12 +33667,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 223) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32672,18 +33690,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); } @@ -32696,7 +33714,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { 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); @@ -32706,14 +33724,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } var rightType = checkNonNullExpression(node.expression); @@ -32879,7 +33897,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); + return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32901,12 +33919,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 151) { + if (func.kind === 152) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 149) { + else if (func.kind === 150) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32924,14 +33942,14 @@ var ts; } } } - else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 262144) { + if (node.flags & 524288) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -32948,8 +33966,9 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); + var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 250 && !hasDuplicateDefaultClause) { + if (clause.kind === 253 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -32961,11 +33980,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 252) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); - if (!isTypeEqualityComparableTo(expressionType, caseType)) { - checkTypeComparableTo(caseType, expressionType, caseClause.expression, undefined); + var caseIsLiteral = isLiteralType(caseType); + var comparedExpressionType = expressionType; + if (!caseIsLiteral || !expressionIsLiteral) { + caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType; + comparedExpressionType = getBaseTypeOfLiteralType(expressionType); + } + if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) { + checkTypeComparableTo(caseType, comparedExpressionType, caseClause.expression, undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -32981,7 +34006,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 218 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -33073,7 +34098,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -33124,7 +34149,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 || declaration.kind === 223) { + if (declaration.kind === 225 || declaration.kind === 226) { if (!firstDecl) { firstDecl = declaration; } @@ -33189,7 +34214,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 222) { + baseType_1.symbol.valueDeclaration.kind === 225) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -33263,7 +34288,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 193) { + if (derivedClassDecl.kind === 196) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -33307,7 +34332,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -33345,8 +34370,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { - var prop = properties_5[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen[prop.name]; if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; @@ -33374,7 +34399,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 226); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -33420,7 +34445,7 @@ var ts; error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { - var text = getTextOfPropertyName(member.name); + var text = ts.getTextOfPropertyName(member.name); if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } @@ -33470,7 +34495,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 189: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -33481,7 +34506,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 191: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -33506,11 +34531,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 182: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 177: + case 176: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -33521,7 +34546,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 177) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -33538,7 +34563,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 176) { current = current.expression; } else { @@ -33598,7 +34623,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 228) { return false; } var enumDeclaration = declaration; @@ -33621,8 +34646,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 222 || - (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 225 || + (declaration.kind === 224 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33681,7 +34706,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 222); + var mergedClass = ts.getDeclarationOfKind(symbol, 225); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33724,36 +34749,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 204: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 236: - case 237: + case 239: + case 240: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 233: + case 234: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 170: - case 219: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 173: + case 222: + var name_28 = node.name; + if (ts.isBindingPattern(name_28)) { + for (var _b = 0, _c = name_28.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 222: case 225: - case 221: - case 223: - case 226: + case 228: case 224: + case 226: + case 229: + case 227: if (isGlobalAugmentation) { return; } @@ -33771,12 +34796,12 @@ var ts; switch (node.kind) { case 70: return node; - case 140: + case 141: do { node = node.left; } while (node.kind !== 70); return node; - case 173: + case 176: do { node = node.expression; } while (node.kind !== 70); @@ -33789,9 +34814,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 237 ? + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { + error(moduleName, node.kind === 240 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33812,7 +34837,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 239 ? + var message = node.kind === 242 ? 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)); @@ -33839,7 +34864,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 236) { checkImportBinding(importClause.namedBindings); } else { @@ -33890,8 +34915,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -33904,7 +34929,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; + var isInAppropriateContext = node.parent.kind === 260 || node.parent.kind === 230 || node.parent.kind === 229; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33927,8 +34952,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 226 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 260 ? node.parent : node.parent.parent; + if (container.kind === 229 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -33995,7 +35020,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 224 && declaration.kind !== 149) || !!declaration.body; } } @@ -34006,118 +35031,121 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 229: + case 225: case 226: - case 222: - case 223: - case 221: + case 224: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 142: - return checkTypeParameter(node); case 143: + return checkTypeParameter(node); + case 144: return checkParameter(node); + case 147: case 146: - case 145: return checkPropertyDeclaration(node); - case 157: case 158: - case 152: + case 159: case 153: - return checkSignatureDeclaration(node); case 154: return checkSignatureDeclaration(node); - case 148: - case 147: - return checkMethodDeclaration(node); - case 149: - return checkConstructorDeclaration(node); - case 150: - case 151: - return checkAccessorDeclaration(node); - case 156: - return checkTypeReferenceNode(node); case 155: + return checkSignatureDeclaration(node); + case 149: + case 148: + return checkMethodDeclaration(node); + case 150: + return checkConstructorDeclaration(node); + case 151: + case 152: + return checkAccessorDeclaration(node); + case 157: + return checkTypeReferenceNode(node); + case 156: return checkTypePredicate(node); - case 159: - return checkTypeQuery(node); case 160: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 161: - return checkArrayType(node); + return checkTypeLiteral(node); case 162: - return checkTupleType(node); + return checkArrayType(node); case 163: + return checkTupleType(node); case 164: - return checkUnionOrIntersectionType(node); case 165: + return checkUnionOrIntersectionType(node); + case 166: + case 168: return checkSourceElement(node.type); - case 221: - return checkFunctionDeclaration(node); - case 200: - case 227: - return checkBlock(node); - case 201: - return checkVariableStatement(node); - case 203: - return checkExpressionStatement(node); - case 204: - return checkIfStatement(node); - case 205: - return checkDoStatement(node); - case 206: - return checkWhileStatement(node); - case 207: - return checkForStatement(node); - case 208: - return checkForInStatement(node); - case 209: - return checkForOfStatement(node); - case 210: - case 211: - return checkBreakOrContinueStatement(node); - case 212: - return checkReturnStatement(node); - case 213: - return checkWithStatement(node); - case 214: - return checkSwitchStatement(node); - case 215: - return checkLabeledStatement(node); - case 216: - return checkThrowStatement(node); - case 217: - return checkTryStatement(node); - case 219: - return checkVariableDeclaration(node); - case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); + case 169: + return checkIndexedAccessType(node); case 224: - return checkTypeAliasDeclaration(node); - case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); - case 231: - return checkImportDeclaration(node); + return checkFunctionDeclaration(node); + case 203: case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 204: + return checkVariableStatement(node); + case 206: + return checkExpressionStatement(node); + case 207: + return checkIfStatement(node); + case 208: + return checkDoStatement(node); + case 209: + return checkWhileStatement(node); + case 210: + return checkForStatement(node); + case 211: + return checkForInStatement(node); + case 212: + return checkForOfStatement(node); + case 213: + case 214: + return checkBreakOrContinueStatement(node); + case 215: + return checkReturnStatement(node); + case 216: + return checkWithStatement(node); + case 217: + return checkSwitchStatement(node); case 218: + return checkLabeledStatement(node); + case 219: + return checkThrowStatement(node); + case 220: + return checkTryStatement(node); + case 222: + return checkVariableDeclaration(node); + case 173: + return checkBindingElement(node); + case 225: + return checkClassDeclaration(node); + case 226: + return checkInterfaceDeclaration(node); + case 227: + return checkTypeAliasDeclaration(node); + case 228: + return checkEnumDeclaration(node); + case 229: + return checkModuleDeclaration(node); + case 234: + return checkImportDeclaration(node); + case 233: + return checkImportEqualsDeclaration(node); + case 240: + return checkExportDeclaration(node); + case 239: + return checkExportAssignment(node); + case 205: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 221: + checkGrammarStatementInAmbientContext(node); + return; + case 243: return checkMissingDeclaration(node); } } @@ -34130,17 +35158,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 180: - case 181: + case 183: + case 184: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 196: checkClassExpressionDeferred(node); break; } @@ -34194,8 +35222,19 @@ var ts; function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { + var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); + var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + if (currentGlobalDiagnostics !== previousGlobalDiagnostics) { + var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics); + return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics); + } + else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) { + return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics); + } + return semanticDiagnostics; } ts.forEach(host.getSourceFiles(), checkSourceFile); return diagnostics.getDiagnostics(); @@ -34212,7 +35251,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 216 && node.parent.statement === node) { return true; } node = node.parent; @@ -34234,28 +35273,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 228: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 196: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 225: + case 226: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 183: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -34294,27 +35333,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: + case 143: case 225: + case 226: + case 227: + case 228: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 140) { + while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 271); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 176) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 198; } function forEachEnclosingClass(node, callback) { var result; @@ -34331,13 +35370,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 140) { + while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230) { + if (nodeOnRightSide.parent.kind === 233) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 239) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34349,7 +35388,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 176) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -34361,11 +35400,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 239 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 230); + if (entityName.kind !== 176 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 233); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34374,7 +35413,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 198) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -34396,14 +35435,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 176) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 140) { + else if (entityName.kind === 141) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -34412,19 +35451,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 271) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 249) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 155) { + if (entityName.parent.kind === 156) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 256) { + if (node.kind === 260) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -34440,8 +35479,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 170 && - node.parent.parent.kind === 168 && + else if (node.parent.kind === 173 && + node.parent.parent.kind === 171 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -34452,8 +35491,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 176: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -34466,18 +35505,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 166: + case 167: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 149) { + if (constructorDeclaration && constructorDeclaration.kind === 150) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 231 || node.parent.kind === 237) && + ((node.parent.kind === 234 || node.parent.kind === 240) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -34485,7 +35524,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 177 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -34499,7 +35538,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 257) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -34549,20 +35588,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 172 || expr.kind === 171); - if (expr.parent.kind === 209) { + ts.Debug.assert(expr.kind === 175 || expr.kind === 174); + if (expr.parent.kind === 212) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 191) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 256) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 171); + ts.Debug.assert(expr.parent.kind === 174); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34598,9 +35637,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_29 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_29); if (symbol) { symbols_3.push(symbol); } @@ -34608,6 +35647,10 @@ var ts; return symbols_3; } else if (symbol.flags & 67108864) { + if (symbol.leftSpread) { + var links = symbol; + return [links.leftSpread, links.rightSpread]; + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -34665,7 +35708,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 260) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -34703,7 +35746,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 203 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34743,16 +35786,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: case 233: case 235: - case 239: + case 236: + case 238: + case 242: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237: + case 240: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 239: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -34762,7 +35805,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 256 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 260 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -34813,7 +35856,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 259) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -34907,9 +35950,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_14 = reference.parent; - if (ts.isDeclaration(parent_14) && reference === parent_14.name) { - location = getDeclarationContainer(parent_14); + var parent_13 = reference.parent; + if (ts.isDeclaration(parent_13) && reference === parent_13.name) { + location = getDeclarationContainer(parent_13); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -34929,7 +35972,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 262144); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -34980,13 +36023,14 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - writeLiteralConstValue: writeLiteralConstValue + writeLiteralConstValue: writeLiteralConstValue, + getJsxFactoryEntity: function () { return _jsxFactoryEntity; } }; function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 176) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -35008,6 +36052,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -35018,15 +36065,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_14 = getParentOfSymbol(current); + if (parent_14) { + current = parent_14; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 260 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35045,7 +36092,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 260); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35075,7 +36122,7 @@ var ts; } } if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 31744; + var fileRequestedExternalEmitHelpers = file.flags & 64512; if (fileRequestedExternalEmitHelpers) { requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; if (firstFileRequestingExternalHelpers === undefined) { @@ -35144,9 +36191,13 @@ var ts; if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { verifyHelperSymbol(exports_2, "__extends", 107455); } - if (requestedExternalEmitHelpers & 16384 && compilerOptions.jsx !== 1) { + if (requestedExternalEmitHelpers & 16384 && + (languageVersion < 5 || compilerOptions.jsx === 2)) { verifyHelperSymbol(exports_2, "__assign", 107455); } + if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { + verifyHelperSymbol(exports_2, "__rest", 107455); + } if (requestedExternalEmitHelpers & 2048) { verifyHelperSymbol(exports_2, "__decorate", 107455); if (compilerOptions.emitDecoratorMetadata) { @@ -35193,14 +36244,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 149 && !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 === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { 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); @@ -35217,17 +36268,17 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 129) { - if (node.kind === 145 || node.kind === 147) { + if (modifier.kind !== 130) { + if (node.kind === 146 || node.kind === 148) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 154) { + if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 225 && node.parent.kind === 222) { + if (node.kind !== 228 && node.parent.kind === 225) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35253,7 +36304,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35276,10 +36327,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -35288,11 +36339,11 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 129: + case 130: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { + else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -35311,10 +36362,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -35326,13 +36377,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35342,14 +36393,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 222) { - if (node.kind !== 148 && - node.kind !== 146 && - node.kind !== 150 && - node.kind !== 151) { + if (node.kind !== 225) { + if (node.kind !== 149 && + node.kind !== 147 && + node.kind !== 151 && + node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 225 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35368,7 +36419,7 @@ var ts; else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -35376,7 +36427,7 @@ var ts; break; } } - if (node.kind === 149) { + if (node.kind === 150) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -35391,13 +36442,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 234 || node.kind === 233) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -35413,37 +36464,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 150: case 151: - case 149: - case 146: - case 145: - case 148: + case 152: + case 150: case 147: - case 154: - case 226: - case 231: - case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 146: + case 149: + case 148: + case 155: + case 229: + case 234: + case 233: + case 240: + case 239: + case 183: + case 184: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 230 || node.parent.kind === 260) { return false; } switch (node.kind) { - case 221: - return nodeHasAnyModifiersExcept(node, 119); - case 222: - return nodeHasAnyModifiersExcept(node, 116); - case 223: - case 201: case 224: - return true; + return nodeHasAnyModifiersExcept(node, 119); case 225: + return nodeHasAnyModifiersExcept(node, 116); + case 226: + case 204: + case 227: + return true; + case 228: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -35456,10 +36507,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 224: + case 183: + case 184: if (!node.asteriskToken) { return false; } @@ -35521,7 +36572,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 184) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -35556,7 +36607,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 !== 133 && parameter.type.kind !== 131) { + if (parameter.type.kind !== 134 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35583,7 +36634,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 194) { + if (arg.kind === 197) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35653,19 +36704,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 141) { + if (node.kind !== 142) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 191 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 221 || - node.kind === 180 || - node.kind === 148); + ts.Debug.assert(node.kind === 224 || + node.kind === 183 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35690,42 +36741,45 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 141) { - checkGrammarComputedPropertyName(name_27); + if (prop.kind === 258) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); + } + if (prop.kind === 257 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 148) { + if (mod.kind !== 119 || prop.kind !== 149) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 253 || prop.kind === 254) { + if (prop.kind === 256 || prop.kind === 257) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + if (name_30.kind === 8) { + checkGrammarNumericLiteral(name_30); } currentKind = Property; } - else if (prop.kind === 148) { + else if (prop.kind === 149) { currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = GetAccessor; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -35735,18 +36789,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35755,19 +36809,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 247) { + if (attr.kind === 250) { continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 248 && !initializer.expression) { + if (initializer && initializer.kind === 251 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -35776,7 +36830,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 223) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35784,20 +36838,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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); @@ -35821,11 +36875,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 150 ? + return grammarErrorOnNode(accessor.name, kind === 151 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 151) { + else if (kind === 152) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35844,10 +36898,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35862,7 +36916,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 175) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -35878,10 +36932,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35892,9 +36946,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 218: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 213 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -35902,8 +36956,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 217: + if (node.kind === 214 && !node.label) { return false; } break; @@ -35916,13 +36970,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 214 ? 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 === 211 + var message = node.kind === 214 ? 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); @@ -35932,9 +36986,9 @@ var ts; if (node.dotDotDotToken) { var elements = node.parent.elements; if (node !== ts.lastOrUndefined(elements)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 169 || node.name.kind === 168) { + if (node.name.kind === 172 || node.name.kind === 171) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35944,11 +36998,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { + if (node.parent.parent.kind !== 211 && node.parent.parent.kind !== 212) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36005,15 +37059,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: case 207: case 208: case 209: + case 216: + case 210: + case 211: + case 212: return false; - case 215: + case 218: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36068,7 +37122,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36076,7 +37130,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36089,13 +37143,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 223 || - node.kind === 224 || - node.kind === 231 || - node.kind === 230 || - node.kind === 237 || - node.kind === 236 || - node.kind === 229 || + if (node.kind === 226 || + node.kind === 227 || + node.kind === 234 || + node.kind === 233 || + node.kind === 240 || + node.kind === 239 || + node.kind === 232 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36104,7 +37158,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 === 201) { + if (ts.isDeclaration(decl) || decl.kind === 204) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36123,7 +37177,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 203 || node.parent.kind === 230 || node.parent.kind === 260) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -36162,49 +37216,49 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[140] = [ + _a[141] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[144] = [ + _a[145] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[178] = [ + _a[181] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[199] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[200] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[228] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[230] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[233] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[244] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[259] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -36217,41 +37271,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return initial; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return initial; } var result = initial; switch (node.kind) { - case 199: case 202: - case 194: - case 218: - case 287: + case 205: + case 197: + case 221: + case 291: break; - case 141: + case 142: result = reduceNode(node.expression, f, result); break; - case 143: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 144: - result = reduceNode(node.expression, f, result); - break; - case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 148: + case 145: + result = reduceNode(node.expression, f, result); + break; + case 147: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 149: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36260,17 +37314,9 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 149: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 150: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 151: @@ -36278,46 +37324,54 @@ var ts; result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 168: - case 169: + case 152: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.body, f, result); + break; + case 171: + case 172: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 173: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 174: result = ts.reduceLeft(node.elements, f, result); break; - case 172: - result = ts.reduceLeft(node.properties, f, result); - break; - case 173: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); - break; - case 174: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); - break; case 175: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.name, f, result); + break; + case 177: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.argumentExpression, f, result); + break; + case 178: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 179: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 180: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 183: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -36325,117 +37379,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 179: case 182: - case 183: - case 184: case 185: - case 191: - case 192: - case 197: - result = reduceNode(node.expression, f, result); - break; case 186: case 187: + case 188: + case 194: + case 195: + case 200: + result = reduceNode(node.expression, f, result); + break; + case 189: + case 190: result = reduceNode(node.operand, f, result); break; - case 188: + case 191: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 192: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 193: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 196: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 195: + case 198: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 201: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 203: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 204: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 206: result = reduceNode(node.expression, f, result); break; - case 204: + case 207: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 208: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 209: + case 216: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 210: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 208: - case 209: + case 211: + case 212: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: - case 216: + case 215: + case 219: result = reduceNode(node.expression, f, result); break; - case 214: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 218: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 220: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 222: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 223: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 224: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36444,7 +37498,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36452,89 +37506,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 231: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 234: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 232: + case 235: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 236: result = reduceNode(node.name, f, result); break; - case 234: - case 238: + case 237: + case 241: result = ts.reduceLeft(node.elements, f, result); break; - case 235: - case 239: + case 238: + case 242: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 239: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 242: + case 245: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 243: - case 244: + case 246: + case 247: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 248: result = reduceNode(node.tagName, f, result); break; - case 246: + case 249: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247: - result = reduceNode(node.expression, f, result); - break; - case 248: - result = reduceNode(node.expression, f, result); - break; - case 249: - result = reduceNode(node.expression, f, result); case 250: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNode(node.expression, f, result); break; case 251: - result = ts.reduceLeft(node.types, f, result); + result = reduceNode(node.expression, f, result); break; case 252: + result = reduceNode(node.expression, f, result); + case 253: + result = ts.reduceLeft(node.statements, f, result); + break; + case 254: + result = ts.reduceLeft(node.types, f, result); + break; + case 255: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 256: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 258: + result = reduceNode(node.expression, f, result); + break; + case 260: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 292: result = reduceNode(node.expression, f, result); break; default: @@ -36559,6 +37616,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -36601,6 +37659,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; + aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -36637,178 +37696,180 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return node; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return node; } switch (node.kind) { - case 199: case 202: - case 194: - case 218: - return node; - case 141: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 143: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 148: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 151: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 168: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 171: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 177: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 182: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 190: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 195: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 200: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 205: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 210: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 212: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 213: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 219: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 220: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 197: case 221: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return node; + case 142: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 144: + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 147: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 149: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 152: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 171: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 172: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 173: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 174: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 175: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 176: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 177: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 178: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 179: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 182: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 184: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 185: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 189: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 190: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 193: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 194: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 195: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 198: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 203: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 204: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 206: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 207: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 208: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 209: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 212: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 213: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 214: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 216: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 217: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 218: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 219: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 222: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 223: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 224: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 225: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 228: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 231: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 232: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 233: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 236: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 237: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 240: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 241: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); case 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 243: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 248: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 252: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 254: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 255: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 256: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 257: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 258: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 260: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 292: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -36912,7 +37973,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor) { + function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { var right = node.right; if (ts.isDestructuringAssignment(right)) { @@ -36931,7 +37992,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); if (needsValue) { expressions.push(value); } @@ -36949,11 +38010,14 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor, transformRest) { var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36966,12 +38030,15 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { var declarations = []; var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -37001,33 +38068,39 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { var pendingAssignments = []; - flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, false, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; function emitAssignment(name, value, location, original) { - var left = nameSubstitution && nameSubstitution(name) || name; - emitPendingAssignment(left, value, location, original); + var expression = createAssignmentCallback + ? createAssignmentCallback(name.kind === 70 ? name : emitTempVariableAssignment(name, location), value, location) + : ts.createAssignment(name, value, location); + emitPendingAssignment(expression, original); } function emitTempVariableAssignment(value, location) { var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(name, value, location, undefined); + emitPendingAssignment(ts.createAssignment(name, value, location), undefined); return name; } - function emitPendingAssignment(name, value, location, original) { - var expression = ts.createAssignment(name, value, location); + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectLiteral(elements), value, location, original); + } + function emitPendingAssignment(expression, original) { expression.original = original; ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); - return expression; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -37058,17 +38131,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 175) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 174) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_32 = ts.getMutableClone(target); + ts.setSourceMapRange(name_32, target); + ts.setCommentRange(name_32, target); + emitAssignment(name_32, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -37076,16 +38149,78 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); } - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; - if (p.kind === 253 || p.kind === 254) { - var propName = p.name; - var target_1 = p.kind === 254 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createDestructuringPropertyAccess(value, propName), p); + var bindingElements = []; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 256 || p.kind === 257) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 256 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 257 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && p.kind === 258) { + ts.Debug.assert(p.expression.kind === 70); + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.expression; + var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); + emitDestructuringAssignment(propName, restCall, p); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; } } function emitArrayLiteralAssignment(target, value, location) { + if (transformRest) { + emitESNextArrayLiteralAssignment(target, value, location); + } + else { + emitES2015ArrayLiteralAssignment(target, value, location); + } + } + function emitESNextArrayLiteralAssignment(target, value, location) { + var elements = target.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, true, location, emitTempVariableAssignment); + } + var expressions = []; + var spreadContainingExpressions = []; + for (var i = 0; i < numElements; i++) { + var e = elements[i]; + if (e.kind === 197) { + continue; + } + if (e.transformFlags & 8388608 && i < numElements - 1) { + var tmp = ts.createTempVariable(recordTempVariable); + spreadContainingExpressions.push([e, tmp]); + expressions.push(tmp); + } + else { + expressions.push(e); + } + } + emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); + for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { + var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; + emitDestructuringAssignment(e, tmp, e); + } + } + function emitES2015ArrayLiteralAssignment(target, value, location) { var elements = target.elements; var numElements = elements.length; if (numElements !== 1) { @@ -37093,8 +38228,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 194) { - if (e.kind !== 192) { + if (e.kind !== 197) { + if (e.kind !== 195) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -37103,42 +38238,130 @@ var ts; } } } + function createRestCall(value, elements, getPropertyName, location) { + var propertyNames = []; + for (var i = 0; i < elements.length - 1; i++) { + if (ts.isOmittedExpression(elements[i])) { + continue; + } + var str = ts.createSynthesizedNode(9); + str.pos = location.pos; + str.end = location.end; + str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); + propertyNames.push(str); + } + var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.createIdentifier("__rest"), undefined, args); + } function emitBindingElement(target, value) { var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (initializer) { + if (transformRest) { + value = value || initializer; + } + else if (initializer) { value = value ? createDefaultValueCheck(value, initializer, target) : initializer; } else if (!value) { value = ts.createVoidZero(); } var name = target.name; - if (ts.isBindingPattern(name)) { - var elements = name.elements; - var numElements = elements.length; + if (!ts.isBindingPattern(name)) { + emitAssignment(name, value, target, target); + } + else { + var numElements = name.elements.length; if (numElements !== 1) { value = ensureIdentifier(value, numElements !== 0, target, emitTempVariableAssignment); } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - else if (name.kind === 168) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } - else { - if (!element.dotDotDotToken) { - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + if (name.kind === 172) { + emitArrayBindingElement(name, value); + } + else { + emitObjectBindingElement(target, value); } } + } + function emitArrayBindingElement(name, value) { + if (transformRest) { + emitESNextArrayBindingElement(name, value); + } else { - emitAssignment(name, value, target, target); + emitES2015ArrayBindingElement(name, value); + } + } + function emitES2015ArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (!element.dotDotDotToken) { + emitBindingElement(element, ts.createElementAccess(value, i)); + } + else if (i === numElements - 1) { + emitBindingElement(element, ts.createArraySlice(value, i)); + } + } + } + function emitESNextArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + var spreadContainingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (element.transformFlags & 8388608 && i < numElements - 1) { + spreadContainingElements.push(element); + bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + } + else { + bindingElements.push(element); + } + } + emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); + for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { + var element = spreadContainingElements_1[_i]; + emitBindingElement(element, ts.getGeneratedNameForNode(element)); + } + } + function emitObjectBindingElement(target, value) { + var name = target.name; + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (i === numElements - 1 && element.dotDotDotToken) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); + emitBindingElement(element, restCall); + } + else if (transformRest && !(element.transformFlags & 8388608)) { + bindingElements.push(element); + } + else { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var propName = element.propertyName || element.name; + emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; } } function createDefaultValueCheck(value, defaultValue, location) { @@ -37191,14 +38414,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(176); + context.enableSubstitution(177); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -37224,7 +38447,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 260) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -37240,13 +38463,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 234: return visitImportDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); - case 236: + case 239: return visitExportAssignment(node); - case 237: + case 240: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -37256,11 +38479,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 237 || - node.kind === 231 || - node.kind === 232 || - (node.kind === 230 && - node.moduleReference.kind === 241)) { + if (node.kind === 240 || + node.kind === 234 || + node.kind === 235 || + (node.kind === 233 && + node.moduleReference.kind === 244)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -37276,21 +38499,30 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 149: - return undefined; - case 146: - case 154: case 150: + return undefined; + case 147: + case 155: case 151: - case 148: + case 152: + case 149: return visitorWorker(node); - case 199: + case 202: return node; default: ts.Debug.failBadSyntaxKind(node); return undefined; } } + function modifierVisitor(node) { + if (ts.modifierToFlag(node.kind) & 2270) { + return undefined; + } + else if (currentNamespace && node.kind === 83) { + return undefined; + } + return node; + } function visitTypeScript(node) { if (ts.hasModifier(node, 2) && ts.isStatement(node)) { return ts.createNotEmittedStatement(node); @@ -37305,78 +38537,80 @@ var ts; case 116: case 75: case 123: - case 129: - case 161: + case 130: case 162: - case 160: - case 155: - case 142: + case 163: + case 161: + case 156: + case 143: case 118: case 121: - case 133: - case 131: - case 128: - case 104: case 134: - case 158: - case 157: + case 132: + case 129: + case 104: + case 135: case 159: - case 156: - case 163: + case 158: + case 160: + case 157: case 164: case 165: case 166: case 167: - case 154: - case 144: - case 224: - case 146: - case 149: - return visitConstructor(node); - case 223: - return ts.createNotEmittedStatement(node); - case 222: - return visitClassDeclaration(node); - case 193: - return visitClassExpression(node); - case 251: - return visitHeritageClause(node); - case 195: - return visitExpressionWithTypeArguments(node); - case 148: - return visitMethodDeclaration(node); + case 168: + case 169: + case 170: + case 155: + case 145: + case 227: + case 147: case 150: - return visitGetAccessor(node); - case 151: - return visitSetAccessor(node); - case 221: - return visitFunctionDeclaration(node); - case 180: - return visitFunctionExpression(node); - case 181: - return visitArrowFunction(node); - case 143: - return visitParameter(node); - case 179: - return visitParenthesizedExpression(node); - case 178: - case 196: - return visitAssertionExpression(node); - case 175: - return visitCallExpression(node); - case 176: - return visitNewExpression(node); - case 197: - return visitNonNullExpression(node); - case 225: - return visitEnumDeclaration(node); - case 201: - return visitVariableStatement(node); - case 219: - return visitVariableDeclaration(node); + return visitConstructor(node); case 226: + return ts.createNotEmittedStatement(node); + case 225: + return visitClassDeclaration(node); + case 196: + return visitClassExpression(node); + case 254: + return visitHeritageClause(node); + case 198: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 182: + return visitParenthesizedExpression(node); + case 181: + case 199: + return visitAssertionExpression(node); + case 178: + return visitCallExpression(node); + case 179: + return visitNewExpression(node); + case 200: + return visitNonNullExpression(node); + case 228: + return visitEnumDeclaration(node); + case 204: + return visitVariableStatement(node); + case 222: + return visitVariableDeclaration(node); + case 229: return visitModuleDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -37385,15 +38619,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 260: + case 231: + case 230: + case 203: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 225: + case 224: if (ts.hasModifier(node, 2)) { break; } @@ -37403,10 +38637,11 @@ var ts; } function visitSourceFile(node) { currentSourceFile = node; - if (compilerOptions.alwaysStrict) { + if (compilerOptions.alwaysStrict && + !(ts.isExternalModule(node) && (compilerOptions.target >= 2 || compilerOptions.module === ts.ModuleKind.ES2015))) { node = ts.ensureUseStrict(node); } - if (node.flags & 31744 + if (node.flags & 64512 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { startLexicalEnvironment(); @@ -37417,10 +38652,10 @@ var ts; externalHelpersModuleImport.parent = node; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); - currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; + currentExternalHelpersModuleName = externalHelpersModuleName; ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - currentSourceFileExternalHelpersModuleName = undefined; + currentExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } @@ -37447,66 +38682,59 @@ var ts; var staticProperties = getInitializedProperties(node, true); var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); - var classAlias; var name = node.name; if (!name && staticProperties.length > 0) { name = ts.getGeneratedNameForNode(node); } - var statements = []; - if (!isDecoratedClass) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - ts.setOriginalNode(classDeclaration, node); - if (staticProperties.length > 0) { - ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); - } - statements.push(classDeclaration); - } - else { - classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); - } + var classStatement = isDecoratedClass + ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) + : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + var statements = [classStatement]; if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, ts.getLocalName(node)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); - addConstructorDecorationStatement(statements, node, classAlias); + addConstructorDecorationStatement(statements, node); if (isNamespaceExport(node)) { addExportMemberAssignment(statements, node); } else if (isDecoratedClass) { if (isDefaultExternalModuleExport(node)) { - statements.push(ts.createExportAssignment(undefined, undefined, false, getLocalName(node))); + statements.push(ts.createExportDefault(ts.getLocalName(node, false, true))); } else if (isNamedExternalModuleExport(node)) { - statements.push(createExternalModuleExport(name)); + statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true))); } } - return statements; + if (statements.length > 1) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432); + } + return ts.singleOrMany(statements); } - function addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause) { + function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var emitFlags = ts.getEmitFlags(node); + if (hasStaticProperties) { + emitFlags |= 1024; + } + ts.setOriginalNode(classDeclaration, node); + ts.setEmitFlags(classDeclaration, emitFlags); + return classDeclaration; + } + function createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) { var location = ts.moveRangePastDecorators(node); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), location), node); - if (!name) { - name = ts.getGeneratedNameForNode(node); - } - var classAlias; - if (resolver.getNodeCheckFlags(node) & 8388608) { - enableSubstitutionForClassAliases(); - classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - } - var declaredName = getDeclarationName(node, true); - var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) - ]), location); - ts.setCommentRange(transformedClassExpression, node); - statements.push(ts.setOriginalNode(transformedClassExpression, node)); - if (classAlias) { - statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(declaredName, undefined, classAlias) - ]), location), node)); - } - return classAlias; + var classAlias = getClassAliasIfNeeded(node); + var declName = ts.getLocalName(node, false, true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = transformClassMembers(node, hasExtendsClause); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + ts.setOriginalNode(classExpression, node); + var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setOriginalNode(statement, node); + ts.setCommentRange(statement, node); + return statement; } function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); @@ -37539,7 +38767,7 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 524288; + var hasParameterPropertyAssignments = node.transformFlags & 4194304; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); @@ -37581,7 +38809,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37615,7 +38843,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 146 + return member.kind === 147 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -37688,12 +38916,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 150: case 151: + case 152: return getAllDecoratorsOfAccessors(node, member); - case 148: + case 149: return getAllDecoratorsOfMethod(member); - case 146: + case 147: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37771,37 +38999,33 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 146 + ? member.kind === 147 ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); ts.setEmitFlags(helper, 49152); return helper; } - function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { - var expression = generateConstructorDecorationExpression(node, decoratedClassAlias); + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); if (expression) { statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); } } - function generateConstructorDecorationExpression(node, decoratedClassAlias) { + function generateConstructorDecorationExpression(node) { var allDecorators = getAllDecoratorsOfConstructor(node); var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators); if (!decoratorExpressions) { return undefined; } - if (decoratedClassAlias) { - var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); - var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } - else { - var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = ts.getLocalName(node, false, true); + var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 49152); + ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); + return expression; } function transformDecorator(decorator) { return ts.visitNode(decorator.expression, visitor, ts.isExpression); @@ -37812,7 +39036,7 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); + var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); ts.setEmitFlags(helper, 49152); expressions.push(helper); } @@ -37830,13 +39054,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -37844,58 +39068,58 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeParameterTypesOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 148 - || kind === 150 + return kind === 149 || kind === 151 - || kind === 146; + || kind === 152 + || kind === 147; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 148; + return node.kind === 149; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 222 - || kind === 193 - || kind === 148 - || kind === 150 - || kind === 151; + return kind === 225 + || kind === 196 + || kind === 149 + || kind === 151 + || kind === 152; } function serializeTypeOfNode(node) { switch (node.kind) { - case 146: - case 143: - case 150: - return serializeTypeNode(node.type); + case 147: + case 144: case 151: + return serializeTypeNode(node.type); + case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 222: - case 193: - case 148: + case 225: + case 196: + case 149: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 161) { + if (node && node.kind === 162) { return node.elementType; } - else if (node && node.kind === 156) { + else if (node && node.kind === 157) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37943,20 +39167,20 @@ var ts; switch (node.kind) { case 104: return ts.createVoidZero(); - case 165: + case 166: return serializeTypeNode(node.type); - case 157: case 158: + case 159: return ts.createIdentifier("Function"); - case 161: case 162: + case 163: return ts.createIdentifier("Array"); - case 155: + case 156: case 121: return ts.createIdentifier("Boolean"); - case 133: + case 134: return ts.createIdentifier("String"); - case 167: + case 170: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -37970,16 +39194,16 @@ var ts; break; } break; - case 131: + case 132: return ts.createIdentifier("Number"); - case 134: + case 135: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 156: + case 157: return serializeTypeReferenceNode(node); + case 165: case 164: - case 163: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -38003,10 +39227,12 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -38048,15 +39274,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + var name_33 = ts.getMutableClone(node); + name_33.flags &= ~8; + name_33.original = undefined; + name_33.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_30; - case 140: + return name_33; + case 141: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -38130,7 +39356,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setCommentRange(method, node); ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); @@ -38143,27 +39369,27 @@ var ts; if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitSetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitFunctionDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); if (isNamespaceExport(node)) { var statements = [func]; @@ -38176,12 +39402,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } @@ -38228,7 +39454,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); @@ -38250,7 +39476,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); @@ -38286,39 +39512,32 @@ var ts; || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } - function shouldEmitVarForEnumDeclaration(node) { - return isFirstEmittedDeclarationInScope(node) - && (!ts.hasModifier(node, 1) - || isES6ExportedDeclaration(node)); - } - function addVarForEnumExportedFromNamespace(statements, node) { - var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - ts.setSourceMapRange(statement, node); - statements.push(statement); - } function visitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { return undefined; } var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForEnumDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); + var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); + moduleArg = ts.createAssignment(localName, moduleArg); + } + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); - if (isNamespaceExport(node)) { - addVarForEnumExportedFromNamespace(statements, node); - } + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformEnumBody(node, localName) { @@ -38353,9 +39572,11 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isES6ExportedDeclaration(node) { - return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES2015; + function hasNamespaceQualifiedExportName(node) { + return isNamespaceExport(node) + || (isExternalModuleExport(node) + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -38370,32 +39591,37 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_34 = node.symbol && node.symbol.name; + if (name_34) { + return currentScopeFirstDeclarationsOfName[name_34] === node; } } return false; } - function shouldEmitVarForModuleDeclaration(node) { - return isFirstEmittedDeclarationInScope(node); - } function addVarForEnumOrModuleDeclaration(statements, node) { - var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) - ? ts.visitNodes(node.modifiers, visitor, ts.isModifier) - : undefined, [ - ts.createVariableDeclaration(getDeclarationName(node, false, true)) + var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), [ + ts.createVariableDeclaration(ts.getLocalName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 225) { - ts.setSourceMapRange(statement.declarationList, node); + recordEmittedDeclarationInScope(node); + if (isFirstEmittedDeclarationInScope(node)) { + if (node.kind === 228) { + ts.setSourceMapRange(statement.declarationList, node); + } + else { + ts.setSourceMapRange(statement, node); + } + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 | 33554432); + statements.push(statement); + return true; } else { - ts.setSourceMapRange(statement, node); + var mergeMarker = ts.createMergeDeclarationMarker(statement); + ts.setEmitFlags(mergeMarker, 49152 | 33554432); + statements.push(mergeMarker); + return false; } - ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768); - statements.push(statement); } function visitModuleDeclaration(node) { if (!shouldEmitModuleDeclaration(node)) { @@ -38405,25 +39631,26 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForModuleDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); - if (ts.hasModifier(node, 1) && !isES6ExportedDeclaration(node)) { - var localName = getLocalName(node); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformModuleBody(node, namespaceLocalName) { @@ -38438,7 +39665,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 230) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -38461,13 +39688,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 230) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 229) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -38487,7 +39714,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 236) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -38539,8 +39766,8 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ - ts.createVariableDeclaration(node.name, undefined, moduleReference) + return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) ]), node), node); } else { @@ -38565,36 +39792,20 @@ var ts; return ts.createStatement(expression, undefined); } function addExportMemberAssignment(statements, node) { - var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); + var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(getNamespaceMemberName(exportName, false, true), exportValue), location); + return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); } - function createExternalModuleExport(exportName) { - return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ - ts.createExportSpecifier(exportName) - ])); - } - function getNamespaceMemberName(name, allowComments, allowSourceMaps) { - var qualifiedName = ts.createPropertyAccess(currentNamespaceContainerName, ts.getSynthesizedClone(name), name); - var emitFlags; - if (!allowComments) { - emitFlags |= 49152; - } - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (emitFlags) { - ts.setEmitFlags(qualifiedName, emitFlags); - } - return qualifiedName; + function createNamespaceExportExpression(exportName, exportValue, location) { + return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { - return getNamespaceMemberName(name, false, true); + return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); @@ -38604,40 +39815,21 @@ var ts; function getNamespaceContainerName(node) { return ts.getGeneratedNameForNode(node); } - function getLocalName(node, noSourceMaps, allowComments) { - return getDeclarationName(node, allowComments, !noSourceMaps, 262144); - } - function getExportName(node, noSourceMaps, allowComments) { - if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); - } - return getDeclarationName(node, allowComments, !noSourceMaps, 131072); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name) { - var name_32 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); - } - return name_32; - } - else { - return ts.getGeneratedNameForNode(node); + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 8388608) { + enableSubstitutionForClassAliases(); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; } } function getClassPrototype(node) { - return ts.createPropertyAccess(getDeclarationName(node), "prototype"); + return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { return ts.hasModifier(member, 32) - ? getDeclarationName(node) + ? ts.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { @@ -38657,15 +39849,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(257); + context.enableEmitNotification(229); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 229; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 228; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38690,14 +39882,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_35 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_35); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -38706,9 +39898,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); } return node; @@ -38736,11 +39928,11 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 226) || - (applicableSubstitutions & 8 && container.kind === 225); + if (container && container.kind !== 260) { + var substitute = (applicableSubstitutions & 2 && container.kind === 229) || + (applicableSubstitutions & 8 && container.kind === 228); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38811,11 +40003,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 245: return visitJsxElement(node, false); - case 243: + case 246: return visitJsxSelfClosingElement(node, false); - case 248: + case 251: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38826,11 +40018,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 251: return visitJsxExpression(node); - case 242: + case 245: return visitJsxElement(node, true); - case 243: + case 246: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38860,7 +40052,7 @@ var ts; objectProperties = ts.singleOrUndefined(segments) || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -38882,7 +40074,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 251) { return visitJsxExpression(node); } else { @@ -38947,16 +40139,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 245) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_36); } } } @@ -39233,6 +40425,163 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + currentSourceFile = node; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16) { + return visitorWorker(node); + } + else if (node.transformFlags & 32) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 175: + return visitObjectLiteralExpression(node); + case 191: + return visitBinaryExpression(node); + case 222: + return visitVariableDeclaration(node); + case 212: + return visitForOfStatement(node); + case 171: + case 172: + return node; + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 258) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 256) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 175) { + objects.unshift(ts.createObjectLiteral()); + } + return ts.createCall(ts.createIdentifier("__assign"), undefined, objects); + } + function visitBinaryExpression(node) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, visitor, true); + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48) { + var result = ts.flattenVariableDestructuring(node, undefined, visitor, undefined, true); + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitForOfStatement(node) { + var initializer = node.initializer; + if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { + return ts.visitEachChild(node, visitor, context); + } + return ts.convertForOf(node, undefined, visitor, ts.noop, context, true); + } + function isRestBindingPattern(initializer) { + if (ts.isVariableDeclarationList(initializer)) { + var declaration = ts.firstOrUndefined(initializer.declarations); + return declaration && declaration.name && + declaration.name.kind === 171 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 175 && + initializer.transformFlags & 8388608; + } + function visitParameter(node) { + if (isObjectRestParameter(node)) { + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, node.initializer, node), node); + } + else { + return node; + } + } + function isObjectRestParameter(node) { + return node.name && + node.name.kind === 171 && + !!(node.name.transformFlags & 8388608); + } + function visitFunctionDeclaration(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + function visitArrowFunction(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + var func = ts.setOriginalNode(ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, body, node), node); + ts.setEmitFlags(func, 256); + return func; + } + function visitFunctionExpression(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + } + ts.transformESNext = transformESNext; +})(ts || (ts = {})); +var ts; (function (ts) { function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; @@ -39257,10 +40606,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16) { + if (node.transformFlags & 64) { return visitorWorker(node); } - else if (node.transformFlags & 32) { + else if (node.transformFlags & 128) { return ts.visitEachChild(node, visitor, context); } return node; @@ -39269,15 +40618,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 188: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 181: + case 184: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39342,9 +40691,10 @@ var ts; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformAsyncFunctionBody(node) { - var nodeType = node.original ? node.original.type : node.type; + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 181; + var isArrowFunction = node.kind === 184; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -39387,12 +40737,14 @@ var ts; } } function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; + if (type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } } } return undefined; @@ -39400,23 +40752,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(175); - context.enableSubstitution(173); - context.enableSubstitution(174); - context.enableEmitNotification(222); - context.enableEmitNotification(148); - context.enableEmitNotification(150); - context.enableEmitNotification(151); + context.enableSubstitution(178); + context.enableSubstitution(176); + context.enableSubstitution(177); + context.enableEmitNotification(225); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); - case 175: + case 178: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -39459,11 +40811,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 225 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -39509,10 +40861,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 64) { + if (node.transformFlags & 256) { return visitorWorker(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -39521,7 +40873,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 191: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39634,11 +40986,11 @@ var ts; return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression; + return isInConstructorWithCapturedSuper && node.kind === 215 && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 218 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { @@ -39648,7 +41000,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39667,15 +41019,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 215: node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 204: return visitVariableStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 211: - case 210: + case 214: + case 213: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39687,76 +41039,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 225: return visitClassDeclaration(node); - case 193: + case 196: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 181: + case 184: return visitArrowFunction(node); - case 180: + case 183: return visitFunctionExpression(node); - case 219: + case 222: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 223: return visitVariableDeclarationList(node); - case 215: + case 218: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); case 208: - return visitForInStatement(node); + return visitDoStatement(node); case 209: + return visitWhileStatement(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: return visitForOfStatement(node); - case 203: + case 206: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 252: - return visitCatchClause(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 255: + return visitCatchClause(node); + case 257: + return visitShorthandPropertyAssignment(node); + case 174: + return visitArrayLiteralExpression(node); + case 178: return visitCallExpression(node); - case 176: - return visitNewExpression(node); case 179: + return visitNewExpression(node); + case 182: return visitParenthesizedExpression(node, true); - case 188: + case 191: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 180: return visitTaggedTemplateExpression(node); - case 190: + case 193: return visitTemplateExpression(node); - case 191: + case 194: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 194: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 260: return visitSourceFileNode(node); - case 201: + case 204: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39771,7 +41123,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 184) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39779,14 +41131,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 204: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 223: + case 222: + case 173: + case 171: + case 172: break; default: enclosingVariableStatement = undefined; @@ -39814,7 +41166,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 184) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39834,13 +41186,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 214 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 211) { + if (node.kind === 214) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39850,7 +41202,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 214) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39880,26 +41232,26 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitClassDeclaration(node) { - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1; - var isDefault = modifierFlags & 512; - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) - ]), node); + var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); + ts.setOriginalNode(variable, node); + var statements = []; + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); ts.setOriginalNode(statement, node); ts.startOnNewLine(statement); - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); - return statements; + statements.push(statement); + if (ts.hasModifier(node, 1)) { + var exportStatement = ts.hasModifier(node, 512) + ? ts.createExportDefault(ts.getLocalName(node)) + : ts.createExternalModuleExport(ts.getLocalName(node)); + ts.setOriginalNode(exportStatement, statement); + statements.push(exportStatement); } - return statement; - } - function isExportModifier(node) { - return node.kind === 83; + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 33554432) === 0) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statement, emitFlags | 33554432); + } + return ts.singleOrMany(statements); } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39909,7 +41261,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39930,7 +41282,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = getLocalName(node); + var localName = ts.getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 49152); @@ -39945,13 +41297,13 @@ var ts; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 256); } @@ -39974,8 +41326,8 @@ var ts; statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); } if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, false); + ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -40002,17 +41354,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 215) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 207) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 203) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40023,7 +41375,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -40032,7 +41384,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -40041,7 +41393,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 206 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -40050,7 +41402,7 @@ var ts; statements.push(ts.createReturn(superCallExpression)); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); if (superCallExpression) { return 1; } @@ -40067,111 +41419,33 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); } else { return node; } } - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 262144) !== 0; - } - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); - } - } - } - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); - } - } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); - } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; - } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536); - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 65536 && node.kind !== 181) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 | 8388608); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 199: + case 202: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 148: + case 149: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 149: + case 150: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40236,7 +41510,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -40247,80 +41521,22 @@ var ts; return transformFunctionLikeToExpression(node, node, node.name); } function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), node), node); } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181) { + if (node.kind !== 184) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } - function transformFunctionBody(node) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 181); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); - ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 179: + case 182: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 191: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -40328,9 +41544,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 182: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 191: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -40376,7 +41592,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 + if (node.transformFlags & 67108864 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -40395,8 +41611,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 211 + && enclosingBlockScopeContainer.kind !== 212 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -40458,68 +41674,7 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(undefined); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); - ts.setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement(undefined, declarationList)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); - } - } - else { - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); - } - else { - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } - ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - ts.setEmitFlags(body, 1536 | 12288); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - ts.setEmitFlags(forStatement, 8192); - return forStatement; + return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, false); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -40527,8 +41682,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 141) { + if (property.transformFlags & 134217728 + || property.name.kind === 142) { numInitialProperties = i; break; } @@ -40583,11 +41738,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 210: + case 211: + case 212: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 223) { loopInitializer = initializer; } break; @@ -40626,7 +41781,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 16777216) !== 0; + && (node.statement.transformFlags & 134217728) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -40634,9 +41789,9 @@ var ts; if (isAsyncBlockContainingAwait) { loopBodyFlags |= 2097152; } - var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ])); + ]), 16777216)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -40694,7 +41849,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 218 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40793,7 +41948,7 @@ var ts; } } else { - loopParameters.push(ts.createParameter(name)); + loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { var outParamName = ts.createUniqueName("out_" + name.text); loopOutParameters.push({ originalName: name, outParamName: outParamName }); @@ -40806,20 +41961,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; - case 253: + case 256: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 257: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40889,7 +42044,7 @@ var ts; ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 1048576) { + if (node.transformFlags & 8388608) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { @@ -40906,35 +42061,35 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 1048576) !== 0); + ts.Debug.assert((node.transformFlags & 8388608) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 174 ? ts.createArraySlice(segments[0]) : segments[0]; } return ts.createArrayConcat(segments.shift(), segments); } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function partitionSpread(node) { + return ts.isSpreadExpression(node) + ? visitSpanOfSpreads + : visitSpanOfNonSpreads; } - function visitSpanOfSpreadElements(chunk) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function visitSpanOfSpreads(chunk) { + return ts.map(chunk, visitExpressionOfSpread); } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); } - function visitExpressionOfSpreadElement(node) { + function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { @@ -41007,7 +42162,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 178 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -41016,7 +42171,7 @@ var ts; var statements = []; startLexicalEnvironment(); ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); + ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); ts.addRange(statements, endLexicalEnvironment()); var clone = ts.getMutableClone(node); @@ -41041,13 +42196,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(149); - context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(149); context.enableEmitNotification(151); - context.enableEmitNotification(181); - context.enableEmitNotification(180); - context.enableEmitNotification(221); + context.enableEmitNotification(152); + context.enableEmitNotification(184); + context.enableEmitNotification(183); + context.enableEmitNotification(224); } } function onSubstituteNode(emitContext, node) { @@ -41072,10 +42227,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: + case 173: case 225: - case 219: + case 228: + case 222: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -41107,28 +42262,8 @@ var ts; } return node; } - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); - } - return name_36; - } - return ts.getGeneratedNameForNode(node); - } function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); + var expression = ts.getLocalName(node); return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { @@ -41140,11 +42275,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 206) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 178) { return false; } var callTarget = statementExpression.expression; @@ -41152,7 +42287,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 195) { return false; } var expression = callArgument.expression; @@ -41208,7 +42343,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 4096) { + if (node.transformFlags & 8192) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -41223,10 +42358,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 2048) { + else if (transformFlags & 4096) { return visitGenerator(node); } - else if (transformFlags & 4096) { + else if (transformFlags & 8192) { return ts.visitEachChild(node, visitor, context); } else { @@ -41235,13 +42370,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 208: return visitDoStatement(node); - case 206: + case 209: return visitWhileStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 215: + case 218: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41249,30 +42384,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 204: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 211: - return visitBreakStatement(node); case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 214: + return visitBreakStatement(node); + case 213: return visitContinueStatement(node); - case 212: + case 215: return visitReturnStatement(node); default: - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (4096 | 33554432)) { + else if (node.transformFlags & (8192 | 268435456)) { return ts.visitEachChild(node, visitor, context); } else { @@ -41282,21 +42417,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: - return visitBinaryExpression(node); - case 189: - return visitConditionalExpression(node); case 191: + return visitBinaryExpression(node); + case 192: + return visitConditionalExpression(node); + case 194: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); case 174: - return visitElementAccessExpression(node); + return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 177: + return visitElementAccessExpression(node); + case 178: return visitCallExpression(node); - case 176: + case 179: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41304,9 +42439,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -41409,7 +42544,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -41463,10 +42598,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 176: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 177: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41658,35 +42793,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200: - return transformAndEmitBlock(node); case 203: - return transformAndEmitExpressionStatement(node); - case 204: - return transformAndEmitIfStatement(node); - case 205: - return transformAndEmitDoStatement(node); + return transformAndEmitBlock(node); case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitExpressionStatement(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitIfStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitDoStatement(node); + case 209: + return transformAndEmitWhileStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitForStatement(node); case 211: - return transformAndEmitBreakStatement(node); - case 212: - return transformAndEmitReturnStatement(node); + return transformAndEmitForInStatement(node); case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitContinueStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitBreakStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitReturnStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitWithStatement(node); case 217: + return transformAndEmitSwitchStatement(node); + case 218: + return transformAndEmitLabeledStatement(node); + case 219: + return transformAndEmitThrowStatement(node); + case 220: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41970,7 +43105,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 250 && defaultClauseIndex === -1) { + if (clause.kind === 253 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41980,7 +43115,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 249) { + if (clause.kind === 252) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -42071,7 +43206,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216) !== 0; + return node && (node.transformFlags & 134217728) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -42402,7 +43537,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -42411,7 +43546,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -42499,7 +43634,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -42770,8 +43905,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(176); + context.enableSubstitution(256); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42830,48 +43965,40 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableSubstitution(254); - context.enableEmitNotification(256); + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableSubstitution(257); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; + var currentModuleInfo; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); } function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { + var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } return updated; @@ -42888,77 +44015,105 @@ var ts; } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return updateSourceFile(node, [ + return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ]); + ], node.statements)); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 128); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); - if (hasExportStarsToExportValues) { + if (currentModuleInfo.hasExportStarsToExportValues) { ts.setEmitFlags(body, 2); } return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals) { + if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 12288 | 49152); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 49152); statements.push(statement); } } } - function visitor(node) { + function sourceElementVisitor(node) { switch (node.kind) { - case 231: + case 234: return visitImportDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); - case 237: + case 240: return visitExportDeclaration(node); - case 236: + case 239: return visitExportAssignment(node); - case 201: + case 204: return visitVariableStatement(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 222: + case 225: return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); default: return node; } } function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; + var statements; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - statements.push(ts.createStatement(createRequireCall(node), node)); + return ts.createStatement(createRequireCall(node), node); } else { var variables = []; @@ -42971,43 +44126,60 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ]))); + ], undefined, languageVersion >= 2 ? 2 : 0))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); } - addExportImportAssignments(statements, node); return ts.singleOrMany(statements); } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); } - ts.setEmitFlags(node.name, 128); - var statements = []; + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); } else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) ], undefined, languageVersion >= 2 ? 2 : 0), node)); } } else { if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); } } - addExportImportAssignments(statements, node); - return statements; + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); } function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { + if (!node.moduleSpecifier) { return undefined; } var generatedName = ts.getGeneratedNameForNode(node); @@ -43021,7 +44193,7 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); + statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); } return ts.singleOrMany(statements); } @@ -43037,195 +44209,248 @@ var ts; if (node.isExportEquals) { return undefined; } - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); } else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512)) { - addExportDefault(statements, getDeclarationName(node), node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); - } - } - function visitVariableStatement(node) { - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 226 || - originalKind === 225 || - originalKind === 222) { - if (!ts.hasModifier(node, 1)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); - } - var resultStatements = []; - if (ts.hasModifier(node, 1)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); } + return ts.singleOrMany(statements); } function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); + var statements; if (ts.hasModifier(node, 1)) { - var isAsync = ts.hasModifier(node, 256); - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); - addExportMemberAssignment(statements, node); + statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); } else { - statements.push(node); + statements = ts.append(statements, node); } - if (node.name) { - addExportMemberAssignments(statements, node.name); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); + var statements; if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); - addExportMemberAssignment(statements, node); + statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); } else { - statements.push(node); + statements = ts.append(statements, node); } - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 225 || origKind === 226) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 222) { - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1)) { + var modifiers = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + } + else { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + } + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - if (ts.hasModifier(original, 1) && - original.kind === 225 && - ts.isFirstDeclarationOfKind(original, 225)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } } - addExportMemberAssignments(statements, original.name); return statements; } - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - ts.setEmitFlags(transformedStatement, 49152); - statements.push(transformedStatement); + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments) { + if (exportName.text === "default") { + var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); + if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 0) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createExportStatement(name, value, location, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value, location) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + if (node.kind === 260) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = ts.createMap(); previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { previousOnEmitNode(emitContext, node, emitCallback); @@ -43233,6 +44458,9 @@ var ts; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); + if (node.id && noSubstitution[node.id]) { + return node; + } if (emitContext === 1) { return substituteExpression(node); } @@ -43257,141 +44485,82 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 188: + case 191: return substituteBinaryExpression(node); - case 187: - case 186: + case 190: + case 189: return substituteUnaryExpression(node); } return node; } function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 260) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name_38 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + } + } + } + return node; } function substituteBinaryExpression(node) { - var left = node.left; - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, node); } - return nestedExportAssignment; + return expression; } } return node; } function substituteUnaryExpression(node) { - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128); - var transformedUnaryExpression = void 0; - if (node.kind === 187) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); - ts.setEmitFlags(transformedUnaryExpression, 128); + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; + return expression; } } return node; } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); - if (container) { - if (container.kind === 256) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; } } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { - var importNode = externalImports_1[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; } var _a; } @@ -43400,7 +44569,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -43409,696 +44578,58 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableEmitNotification(256); - var exportFunctionForFileMap = []; + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); + var exportFunctionsMap = ts.createMap(); + var noSubstitutionMap = ts.createMap(); var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; + var moduleInfo; + var exportFunction; + var contextObject; + var hoistedStatements; var enclosingBlockScopedContainer; - var currentParent; - var currentNode; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - addSystemModuleBody(statements, node, dependencyGroups); + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + enclosingBlockScopedContainer = node; + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + contextObject = ts.createUniqueName("context"); + var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, exportFunction), + ts.createParameter(undefined, undefined, undefined, contextObject) + ], undefined, createSystemModuleBody(node, dependencyGroups)); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); - return updateSourceFile(node, [ + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], ~1 & ts.getEmitFlags(node)); - var _a; - } - function addSystemModuleBody(statements, node, dependencyGroups) { - startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - ts.addRange(statements, endLexicalEnvironment()); - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction])) + ], node.statements)); + ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1); + if (noSubstitution) { + noSubstitutionMap[id] = noSubstitution; + noSubstitution = undefined; } - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { - var externalImport = externalImports_2[_i]; - if (externalImport.kind === 237 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return addExportStarFunction(statements, undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 237) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 231: - if (!entry.importClause) { - break; - } - case 230: - ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 237: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); - } - else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); - } - return ts.createArrayLiteral(setters, undefined, true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 231: - return visitImportDeclaration(node); - case 230: - return visitImportEqualsDeclaration(node); - case 237: - return visitExportDeclaration(node); - case 236: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 201: - return visitVariableStatement(node); - case 221: - return visitFunctionDeclaration(node); - case 222: - return visitClassDeclaration(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 209: - return visitForOfStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 215: - return visitLabeledStatement(node); - case 213: - return visitWithStatement(node); - case 214: - return visitSwitchStatement(node); - case 228: - return visitCaseBlock(node); - case 249: - return visitCaseClause(node); - case 250: - return visitDefaultClause(node); - case 217: - return visitTryStatement(node); - case 252: - return visitCatchClause(node); - case 200: - return visitBlock(node); - case 203: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - return createExportStatement(ts.createLiteral("default"), node.expression); - } - function visitVariableStatement(node) { - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || - enclosingBlockScopedContainer.kind === 256; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - function transformVariable(node, isExported) { - hoistBindingElement(node, isExported); - if (!node.initializer) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - return ts.createAssignment(name, node.initializer); - } - else { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); - } - } - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_42); - } - return [ - node, - createExportStatement(name_42, name_42) - ]; - } - return node; - } - function visitClassDeclaration(node) { - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); - if (ts.hasModifier(node, 1)) { - if (!ts.hasModifier(node, 512)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; - } - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); - } - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 188: - return substituteBinaryExpression(node); - case 186: - case 187: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128); - var left = node.left; - switch (left.kind) { - case 70: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 172: - case 171: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 70: - return isExportedBinding(node); - case 172: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 171: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 57 - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 70 - || kind === 172 - || kind === 171; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 187 || - (node.kind === 186 && (operator === 42 || operator === 43))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128); - var call = createExportExpression(operand, expr); - if (node.kind === 186) { - return call; - } - else { - return operator === 42 - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ - ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) - ], undefined, true))); - return exportStarFunction; - } - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); - } - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + contextObject = undefined; + hoistedStatements = undefined; + enclosingBlockScopedContainer = undefined; + return ts.aggregateTransformFlags(updated); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -44110,7 +44641,6 @@ var ts; if (ts.hasProperty(groupIndices, text)) { var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; } else { groupIndices[text] = dependencyGroups.length; @@ -44122,47 +44652,722 @@ var ts; } return dependencyGroups; } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; + function createSystemModuleBody(node, dependencyGroups) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) + ]))); + var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + ts.addRange(statements, hoistedStatements); + ts.addRange(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ]), true))); + var body = ts.createBlock(statements, undefined, true); + ts.setEmitFlags(body, 1); + return body; } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { + function addExportStarIfNeeded(statements) { + if (!moduleInfo.hasExportStarsToExportValues) { return; } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); + if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { + var externalImport = _a[_i]; + if (externalImport.kind === 240 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + var exportStarFunction_1 = createExportStarFunction(undefined); + statements.push(exportStarFunction_1); + return exportStarFunction_1.name; } } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + var exportedNames = []; + if (moduleInfo.exportedNames) { + for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) { + var exportedLocalName = _c[_b]; + if (exportedLocalName.text === "default") { + continue; + } + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + } + } + for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { + var externalImport = _e[_d]; + if (externalImport.kind !== 240) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { + var element = _g[_f]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ]))); + var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); + statements.push(exportStarFunction); + return exportStarFunction.name; + } + function createExportStarFunction(localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + } + return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([ + ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ])), + ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) + ], undefined, true)); + } + function createSettersArray(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 234: + if (!entry.importClause) { + break; + } + case 233: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 240: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + } + else { + statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + } + return ts.createArrayLiteral(setters, undefined, true); + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 234: + return visitImportDeclaration(node); + case 233: + return visitImportEqualsDeclaration(node); + case 240: + return undefined; + case 239: + return visitExportAssignment(node); + default: + return nestedElementVisitor(node); } } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, true); + function visitImportDeclaration(node) { + var statements; + if (node.importClause) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, false); + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var expression = ts.visitNode(node.expression, destructuringVisitor, ts.isExpression); + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true); + } + else { + return createExportStatement(ts.createIdentifier("default"), expression, true); + } + } + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1)) { + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + } + else { + hoistedStatements = ts.append(hoistedStatements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); + } + return undefined; + } + function visitClassDeclaration(node) { + var statements; + var name = ts.getLocalName(node); + hoistVariableDeclaration(name); + statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + if (!shouldHoistVariableDeclarationList(node.declarationList)) { + return ts.visitNode(node, destructuringVisitor, ts.isStatement); + } + var expressions; + var isExportedDeclaration = ts.hasModifier(node, 1); + var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } + var statements; + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + if (isMarkedDeclaration) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + } + else { + statements = appendExportsOfVariableStatement(statements, node, false); + } + return ts.singleOrMany(statements); + } + function hoistBindingElement(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + hoistBindingElement(element); + } + } + } + else { + hoistVariableDeclaration(ts.getSynthesizedClone(node.name)); + } + } + function shouldHoistVariableDeclarationList(node) { + return (ts.getEmitFlags(node) & 16777216) === 0 + && (enclosingBlockScopedContainer.kind === 260 + || (ts.getOriginalNode(node).flags & 3) === 0); + } + function transformInitializedVariable(node, isExportedDeclaration) { + var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; + return ts.isBindingPattern(node.name) + ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); + } + function createExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, true); + } + function createNonExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, false); + } + function createVariableAssignment(name, value, location, isExportedDeclaration) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + return isExportedDeclaration + ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) + : preventSubstitution(ts.createAssignment(name, value, location)); + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + var isExportedDeclaration = ts.hasModifier(node.original, 1); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.initializer || exportSelf) { + statements = appendExportsOfBindingElement(statements, decl, exportSelf); + } + } + return statements; + } + function appendExportsOfBindingElement(statements, decl, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element, exportSelf); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + var excludeName = void 0; + if (exportSelf) { + statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl)); + excludeName = decl.name.text; + } + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var excludeName; + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl)); + excludeName = exportName.text; + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl, excludeName) { + if (moduleInfo.exportEquals) { + return statements; + } + var name = ts.getDeclarationName(decl); + var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; + if (exportSpecifier.name.text !== excludeName) { + statements = appendExportStatement(statements, exportSpecifier.name, name); + } + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, allowComments)); + return statements; + } + function createExportStatement(name, value, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value)); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; + return ts.createCall(exportFunction, undefined, [exportName, value]); + } + function nestedElementVisitor(node) { + switch (node.kind) { + case 204: + return visitVariableStatement(node); + case 224: + return visitFunctionDeclaration(node); + case 225: + return visitClassDeclaration(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: + return visitForOfStatement(node); + case 208: + return visitDoStatement(node); + case 209: + return visitWhileStatement(node); + case 218: + return visitLabeledStatement(node); + case 216: + return visitWithStatement(node); + case 217: + return visitSwitchStatement(node); + case 231: + return visitCaseBlock(node); + case 252: + return visitCaseClause(node); + case 253: + return visitDefaultClause(node); + case 220: + return visitTryStatement(node); + case 255: + return visitCatchClause(node); + case 203: + return visitBlock(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); + default: + return destructuringVisitor(node); + } + } + function visitForStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForInStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForOfStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function shouldHoistForInitializer(node) { + return ts.isVariableDeclarationList(node) + && shouldHoistVariableDeclarationList(node); + } + function visitForInitializer(node) { + if (shouldHoistForInitializer(node)) { + var expressions = void 0; + for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + expressions = ts.append(expressions, transformInitializedVariable(variable, false)); + } + return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression(); + } + else { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + } + function visitDoStatement(node) { + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + } + function visitWhileStatement(node) { + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitLabeledStatement(node) { + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitWithStatement(node) { + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitSwitchStatement(node) { + return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + } + function visitCaseBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitCaseClause(node) { + return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + } + function visitDefaultClause(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitTryStatement(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitCatchClause(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.visitEachChild(node, nestedElementVisitor, context); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function destructuringVisitor(node) { + if (node.transformFlags & 16384 + && node.kind === 191) { + return visitDestructuringAssignment(node); + } + else if (node.transformFlags & 32768) { + return ts.visitEachChild(node, destructuringVisitor, context); + } + else { + return node; + } + } + function visitDestructuringAssignment(node) { + if (hasExportedReferenceInDestructuringTarget(node.left)) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, destructuringVisitor); + } + return ts.visitEachChild(node, destructuringVisitor, context); + } + function hasExportedReferenceInDestructuringTarget(node) { + if (ts.isAssignmentExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.left); + } + else if (ts.isSpreadExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.expression); + } + else if (ts.isObjectLiteralExpression(node)) { + return ts.some(node.properties, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isArrayLiteralExpression(node)) { + return ts.some(node.elements, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.initializer); + } + else if (ts.isIdentifier(node)) { + var container = resolver.getReferencedExportContainer(node); + return container !== undefined && container.kind === 260; + } + else { + return false; + } + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260) { + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; + if (noSubstitution) { + delete noSubstitutionMap[id]; + } + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (isSubstitutionPrevented(node)) { + return node; + } + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 191: + return substituteBinaryExpression(node); + case 189: + case 190: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + } + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createPrefix(node.operator, node.operand, node) + : node; + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 190) { + expression = node.operator === 42 + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); + } + return expression; + } + } + return node; + } + function getExports(name) { + var exportedNames; + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + var exportContainer = resolver.getReferencedExportContainer(name, false); + if (exportContainer && exportContainer.kind === 260) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); + } + } + return exportedNames; + } + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = ts.createMap(); + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } } ts.transformSystemModule = transformSystemModule; @@ -44183,9 +45388,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 233: return undefined; - case 236: + case 239: return visitExportAssignment(node); } return node; @@ -44212,10 +45417,12 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; transformers.push(ts.transformTypeScript); - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (jsx === 2) { transformers.push(ts.transformJsx); } + if (languageVersion < 5) { + transformers.push(ts.transformESNext); + } if (languageVersion < 4) { transformers.push(ts.transformES2017); } @@ -44226,6 +45433,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -44235,7 +45443,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(295); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -44432,7 +45640,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 231); + ts.Debug.assert(aliasEmitInfo.node.kind === 234); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -44503,10 +45711,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 222) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 237 || declaration.kind === 238 || declaration.kind === 235) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -44517,7 +45725,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 231) { + if (moduleElementEmitInfo.node.kind === 234) { moduleElementEmitInfo.isVisible = true; } else { @@ -44525,12 +45733,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -44643,43 +45851,47 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 166: + case 129: case 167: + case 170: return writeTextOfNode(currentText, type); - case 195: + case 198: return emitExpressionWithTypeArguments(type); - case 156: - return emitTypeReference(type); - case 159: - return emitTypeQuery(type); - case 161: - return emitArrayType(type); - case 162: - return emitTupleType(type); - case 163: - return emitUnionType(type); - case 164: - return emitIntersectionType(type); - case 165: - return emitParenType(type); case 157: - case 158: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 160: + return emitTypeQuery(type); + case 162: + return emitArrayType(type); + case 163: + return emitTupleType(type); + case 164: + return emitUnionType(type); + case 165: + return emitIntersectionType(type); + case 166: + return emitParenType(type); + case 168: + return emitTypeOperator(type); + case 169: + return emitPropertyAccessType(type); + case 158: + case 159: + return emitSignatureDeclarationWithJsDocComments(type); + case 161: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 140: + case 141: return emitEntityName(type); - case 155: + case 156: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -44687,22 +45899,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 140 ? entityName.left : entityName.expression; - var right = entityName.kind === 140 ? entityName.right : entityName.name; + var left = entityName.kind === 141 ? entityName.left : entityName.expression; + var right = entityName.kind === 141 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 233 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 176); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44748,6 +45960,17 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitPropertyAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -44776,9 +45999,9 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -44822,10 +46045,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 233 || + (node.parent.kind === 260 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 260) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -44834,7 +46057,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 234) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44852,30 +46075,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221: - return writeFunctionDeclaration(node); - case 201: - return writeVariableStatement(node); - case 223: - return writeInterfaceDeclaration(node); - case 222: - return writeClassDeclaration(node); case 224: - return writeTypeAliasDeclaration(node); - case 225: - return writeEnumDeclaration(node); + return writeFunctionDeclaration(node); + case 204: + return writeVariableStatement(node); case 226: + return writeInterfaceDeclaration(node); + case 225: + return writeClassDeclaration(node); + case 227: + return writeTypeAliasDeclaration(node); + case 228: + return writeEnumDeclaration(node); + case 229: return writeModuleDeclaration(node); - case 230: + case 233: return writeImportEqualsDeclaration(node); - case 231: + case 234: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 260) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -44883,7 +46106,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 226 && !noDeclare) { write("declare "); } } @@ -44933,7 +46156,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 236) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44956,7 +46179,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 236) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44973,13 +46196,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 229; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 233) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 229) { moduleSpecifier = parent.name; } else { @@ -45047,7 +46270,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 230) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -45117,7 +46340,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -45127,15 +46350,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - (node.parent.parent && node.parent.parent.kind === 160)) { - ts.Debug.assert(node.parent.kind === 148 || - node.parent.kind === 147 || - node.parent.kind === 157 || + if (node.parent.kind === 158 || + node.parent.kind === 159 || + (node.parent.parent && node.parent.parent.kind === 161)) { + ts.Debug.assert(node.parent.kind === 149 || + node.parent.kind === 148 || node.parent.kind === 158 || - node.parent.kind === 152 || - node.parent.kind === 153); + node.parent.kind === 159 || + node.parent.kind === 153 || + node.parent.kind === 154); emitType(node.constraint); } else { @@ -45145,31 +46368,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { 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 === 222) { + else if (node.parent.parent.kind === 225) { 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 221: + case 224: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -45206,7 +46429,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 225) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -45286,17 +46509,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 222 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 146 || node.kind === 145 || - (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 147 || node.kind === 146 || + (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { + if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -45309,14 +46532,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 146 || node.kind === 145) { + else if (node.kind === 147 || node.kind === 146) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45324,7 +46547,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 === 222) { + else if (node.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45350,7 +46573,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 194) { + if (element.kind !== 197) { elements.push(element); } } @@ -45416,7 +46639,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -45429,7 +46652,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 150 + return accessor.kind === 151 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -45438,7 +46661,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 151) { + if (accessorWithTypeAnnotation.kind === 152) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -45484,17 +46707,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 224) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 148 || node.kind === 149) { + else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 221) { + if (node.kind === 224) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -45514,15 +46737,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 154) { + if (node.kind === 155) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 153 || node.kind === 158) { + if (node.kind === 154 || node.kind === 159) { write("new "); } - else if (node.kind === 157) { + else if (node.kind === 158) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -45533,20 +46756,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 154) { + if (node.kind === 155) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; - if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { + var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; + if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -45560,23 +46783,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 153: + case 154: 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 152: + case 153: 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 154: + case 155: 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 149: case 148: - case 147: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45584,7 +46807,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 === 222) { + else if (node.parent.kind === 225) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -45597,7 +46820,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 224: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -45629,9 +46852,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - node.parent.parent.kind === 160) { + if (node.parent.kind === 158 || + node.parent.kind === 159 || + node.parent.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -45647,22 +46870,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 149: + case 150: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 153: + case 154: 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 152: + case 153: 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 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45670,7 +46893,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 === 222) { + else if (node.parent.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45682,7 +46905,7 @@ 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 221: + case 224: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45693,12 +46916,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -45709,10 +46932,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 197) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 173) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45734,39 +46957,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: case 224: + case 229: + case 233: + case 226: case 225: + case 227: + case 228: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 204: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 234: return emitModuleElement(node, !node.importClause); - case 237: + case 240: return emitExportDeclaration(node); + case 150: case 149: case 148: - case 147: return writeFunctionDeclaration(node); - case 153: - case 152: case 154: + case 153: + case 155: return emitSignatureDeclarationWithJsDocComments(node); - case 150: case 151: + case 152: return emitAccessorDeclaration(node); + case 147: case 146: - case 145: return emitPropertyDeclaration(node); - case 255: + case 259: return emitEnumMemberDeclaration(node); - case 236: + case 239: return emitExportAssignment(node); - case 256: + case 260: return emitSourceFile(node); } } @@ -45983,7 +47206,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45996,7 +47219,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -46140,7 +47363,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 291; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -46154,7 +47377,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 223) { declarationListContainerEnd = end; } } @@ -46361,6 +47584,7 @@ var ts; var brackets = createBracketsMap(); var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; + var restHelper = "\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))\n t[p] = s[p];\n return t;\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -46393,6 +47617,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -46526,7 +47751,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 260: return emitSourceFile(node); } } @@ -46564,7 +47789,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -46578,182 +47802,189 @@ var ts; case 137: case 138: case 139: + case 140: writeTokenText(kind); return; - case 140: - return emitQualifiedName(node); case 141: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 142: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 143: - return emitParameter(node); + return emitTypeParameter(node); case 144: - return emitDecorator(node); + return emitParameter(node); case 145: - return emitPropertySignature(node); + return emitDecorator(node); case 146: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 147: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 148: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 149: - return emitConstructor(node); + return emitMethodDeclaration(node); case 150: + return emitConstructor(node); case 151: - return emitAccessorDeclaration(node); case 152: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 153: - return emitConstructSignature(node); + return emitCallSignature(node); case 154: - return emitIndexSignature(node); + return emitConstructSignature(node); case 155: - return emitTypePredicate(node); + return emitIndexSignature(node); case 156: - return emitTypeReference(node); + return emitTypePredicate(node); case 157: - return emitFunctionType(node); + return emitTypeReference(node); case 158: - return emitConstructorType(node); + return emitFunctionType(node); case 159: - return emitTypeQuery(node); + return emitConstructorType(node); case 160: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 161: - return emitArrayType(node); + return emitTypeLiteral(node); case 162: - return emitTupleType(node); + return emitArrayType(node); case 163: - return emitUnionType(node); + return emitTupleType(node); case 164: - return emitIntersectionType(node); + return emitUnionType(node); case 165: - return emitParenthesizedType(node); - case 195: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 166: - return emitThisType(); - case 167: - return emitLiteralType(node); - case 168: - return emitObjectBindingPattern(node); - case 169: - return emitArrayBindingPattern(node); - case 170: - return emitBindingElement(node); + return emitParenthesizedType(node); case 198: - return emitTemplateSpan(node); - case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitPropertyAccessType(node); + case 170: + return emitLiteralType(node); + case 171: + return emitObjectBindingPattern(node); + case 172: + return emitArrayBindingPattern(node); + case 173: + return emitBindingElement(node); case 201: - return emitVariableStatement(node); + return emitTemplateSpan(node); case 202: - return emitEmptyStatement(); + return emitSemicolonClassElement(); case 203: - return emitExpressionStatement(node); + return emitBlock(node); case 204: - return emitIfStatement(node); + return emitVariableStatement(node); case 205: - return emitDoStatement(node); + return emitEmptyStatement(); case 206: - return emitWhileStatement(node); + return emitExpressionStatement(node); case 207: - return emitForStatement(node); + return emitIfStatement(node); case 208: - return emitForInStatement(node); + return emitDoStatement(node); case 209: - return emitForOfStatement(node); + return emitWhileStatement(node); case 210: - return emitContinueStatement(node); + return emitForStatement(node); case 211: - return emitBreakStatement(node); + return emitForInStatement(node); case 212: - return emitReturnStatement(node); + return emitForOfStatement(node); case 213: - return emitWithStatement(node); + return emitContinueStatement(node); case 214: - return emitSwitchStatement(node); + return emitBreakStatement(node); case 215: - return emitLabeledStatement(node); + return emitReturnStatement(node); case 216: - return emitThrowStatement(node); + return emitWithStatement(node); case 217: - return emitTryStatement(node); + return emitSwitchStatement(node); case 218: - return emitDebuggerStatement(node); + return emitLabeledStatement(node); case 219: - return emitVariableDeclaration(node); + return emitThrowStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitTryStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitDebuggerStatement(node); case 222: - return emitClassDeclaration(node); + return emitVariableDeclaration(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclarationList(node); case 224: - return emitTypeAliasDeclaration(node); + return emitFunctionDeclaration(node); case 225: - return emitEnumDeclaration(node); + return emitClassDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitInterfaceDeclaration(node); case 227: - return emitModuleBlock(node); + return emitTypeAliasDeclaration(node); case 228: - return emitCaseBlock(node); + return emitEnumDeclaration(node); + case 229: + return emitModuleDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleBlock(node); case 231: - return emitImportDeclaration(node); - case 232: - return emitImportClause(node); + return emitCaseBlock(node); case 233: - return emitNamespaceImport(node); + return emitImportEqualsDeclaration(node); case 234: - return emitNamedImports(node); + return emitImportDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportClause(node); case 236: - return emitExportAssignment(node); + return emitNamespaceImport(node); case 237: - return emitExportDeclaration(node); + return emitNamedImports(node); case 238: - return emitNamedExports(node); + return emitImportSpecifier(node); case 239: - return emitExportSpecifier(node); + return emitExportAssignment(node); case 240: - return; + return emitExportDeclaration(node); case 241: + return emitNamedExports(node); + case 242: + return emitExportSpecifier(node); + case 243: + return; + case 244: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 244: - return emitJsxOpeningElement(node); - case 245: - return emitJsxClosingElement(node); - case 246: - return emitJsxAttribute(node); case 247: - return emitJsxSpreadAttribute(node); + return emitJsxOpeningElement(node); case 248: - return emitJsxExpression(node); + return emitJsxClosingElement(node); case 249: - return emitCaseClause(node); + return emitJsxAttribute(node); case 250: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxExpression(node); case 252: - return emitCatchClause(node); + return emitCaseClause(node); case 253: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 255: + return emitCatchClause(node); + case 256: + return emitPropertyAssignment(node); + case 257: + return emitShorthandPropertyAssignment(node); + case 258: + return emitSpreadAssignment(node); + case 259: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -46778,63 +48009,63 @@ var ts; case 98: writeTokenText(kind); return; - case 171: - return emitArrayLiteralExpression(node); - case 172: - return emitObjectLiteralExpression(node); - case 173: - return emitPropertyAccessExpression(node); case 174: - return emitElementAccessExpression(node); + return emitArrayLiteralExpression(node); case 175: - return emitCallExpression(node); + return emitObjectLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitPropertyAccessExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitElementAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitCallExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitNewExpression(node); case 180: - return emitFunctionExpression(node); + return emitTaggedTemplateExpression(node); case 181: - return emitArrowFunction(node); + return emitTypeAssertionExpression(node); case 182: - return emitDeleteExpression(node); + return emitParenthesizedExpression(node); case 183: - return emitTypeOfExpression(node); + return emitFunctionExpression(node); case 184: - return emitVoidExpression(node); + return emitArrowFunction(node); case 185: - return emitAwaitExpression(node); + return emitDeleteExpression(node); case 186: - return emitPrefixUnaryExpression(node); + return emitTypeOfExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitVoidExpression(node); case 188: - return emitBinaryExpression(node); + return emitAwaitExpression(node); case 189: - return emitConditionalExpression(node); + return emitPrefixUnaryExpression(node); case 190: - return emitTemplateExpression(node); + return emitPostfixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitBinaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitConditionalExpression(node); case 193: - return emitClassExpression(node); + return emitTemplateExpression(node); case 194: - return; + return emitYieldExpression(node); + case 195: + return emitSpreadExpression(node); case 196: - return emitAsExpression(node); + return emitClassExpression(node); case 197: + return; + case 199: + return emitAsExpression(node); + case 200: return emitNonNullExpression(node); - case 242: + case 245: return emitJsxElement(node); - case 243: + case 246: return emitJsxSelfClosingElement(node); - case 288: + case 292: return emitPartiallyEmittedExpression(node); } } @@ -46938,7 +48169,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 150 ? "get " : "set "); + write(node.kind === 151 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -47023,6 +48254,17 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitPropertyAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -47186,7 +48428,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 189 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -47230,7 +48472,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -47298,7 +48540,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 207) { write(" "); emit(node.elseStatement); } @@ -47360,7 +48602,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 223) { emit(node); } else { @@ -47589,7 +48831,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 229) { write("."); emit(body.name); body = body.body; @@ -47808,6 +49050,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } function emitEnumMember(node) { emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); @@ -47877,10 +49125,17 @@ var ts; extendsEmitted = true; helpersEmitted = true; } - if (compilerOptions.jsx !== 1 && !assignEmitted && (node.flags & 16384)) { + if ((languageVersion < 5 || currentSourceFile.scriptKind === 2 || currentSourceFile.scriptKind === 4) && + compilerOptions.jsx !== 1 && + !assignEmitted && + node.flags & 16384) { writeLines(assignHelper); assignEmitted = true; } + if (languageVersion < 5 && !restEmitted && node.flags & 32768) { + writeLines(restHelper); + restEmitted = true; + } if (!decorateEmitted && node.flags & 2048) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -48203,7 +49458,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 182 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -48260,21 +49515,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { + var name_40 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_44; + return name_40; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_45 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -48312,17 +49567,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 229: + case 228: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 234: + case 240: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 224: + case 225: + case 239: return generateNameForExportDefault(); - case 193: + case 196: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -48395,7 +49650,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.2"; + ts.version = "2.1.3"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -48610,11 +49865,11 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_42 = names_1[_i]; + var result = name_42 in cache + ? cache[name_42] + : cache[name_42] = loader(name_42, containingFile); resolutions.push(result); } return resolutions; @@ -48628,7 +49883,7 @@ var ts; var classifiableNames; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; var currentNodeModulesDepth = 0; var modulesWithElidedImports = ts.createMap(); var sourceFilesFoundSearchingNodeModules = ts.createMap(); @@ -48641,7 +49896,14 @@ var ts; var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); var resolveModuleNamesWorker; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { + if (!resolved || resolved.extension !== undefined) { + return resolved; + } + var withExtension = ts.clone(resolved); + withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); + return withExtension; + }); }; } else { var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; @@ -48703,6 +49965,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -48734,6 +49997,79 @@ var ts; } return classifiableNames; } + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + if (!oldProgramState && !file.ambientModuleNames.length) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var unknownModuleNames; + var result; + var predictedToResolveToAmbientModuleMarker = {}; + for (var i = 0; i < moduleNames.length; i++) { + var moduleName = moduleNames[i]; + var isKnownToResolveToAmbientModule = false; + if (ts.contains(file.ambientModuleNames, moduleName)) { + isKnownToResolveToAmbientModule = 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); + } + } + else { + isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + } + if (isKnownToResolveToAmbientModule) { + if (!unknownModuleNames) { + result = new Array(moduleNames.length); + unknownModuleNames = moduleNames.slice(0, i); + } + result[i] = predictedToResolveToAmbientModuleMarker; + } + else if (unknownModuleNames) { + unknownModuleNames.push(moduleName); + } + } + if (!unknownModuleNames) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var resolutions = unknownModuleNames.length + ? resolveModuleNamesWorker(unknownModuleNames, containingFile) + : emptyArray; + var j = 0; + for (var i = 0; i < result.length; i++) { + if (result[i] == predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } + else { + result[i] = resolutions[j]; + j++; + } + } + ts.Debug.assert(j === resolutions.length); + return result; + function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { + if (!oldProgramState) { + return false; + } + var resolutionToFile = ts.getResolvedModule(oldProgramState.file, moduleName); + if (resolutionToFile) { + return false; + } + var ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + if (!(ambientModule && ambientModule.declarations)) { + return false; + } + var firstUnmodifiedFile = ts.forEach(ambientModule.declarations, function (d) { + var f = ts.getSourceFileOfNode(d); + return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && f; + }); + if (!firstUnmodifiedFile) { + return false; + } + if (ts.isTraceEnabled(options, host)) { + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + } + return true; + } + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return false; @@ -48780,40 +50116,44 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { return false; } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else { newSourceFile = oldSourceFile; } newSourceFiles.push(newSourceFile); } + var modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths: modifiedFilePaths }); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } for (var i = 0, len = newSourceFiles.length; i < len; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + for (var _d = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _d < modifiedSourceFiles_2.length; _d++) { + var modifiedFile = modifiedSourceFiles_2[_d]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); oldProgram.structureIsReused = true; @@ -48829,11 +50169,14 @@ var ts; getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, }; } + function isSourceFileFromExternalLibrary(file) { + return sourceFilesFoundSearchingNodeModules[file.path]; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -48910,6 +50253,12 @@ var ts; } } function getSyntacticDiagnosticsForFile(sourceFile) { + if (ts.isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); + } return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -48929,175 +50278,163 @@ var ts; var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; + var parent = sourceFile; walk(sourceFile); return diagnostics; function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 230: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 236: - if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 222: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251: - var heritageClause = node; - if (heritageClause.token === 107) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 223: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 226: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 224: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 148: + switch (parent.kind) { + case 144: case 147: + if (parent.questionToken === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return; + } case 149: + case 148: case 150: case 151: - case 180: - case 221: + case 152: + case 183: + case 224: + case 184: + case 224: + case 222: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 233: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 239: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 254: + var heritageClause = node; + if (heritageClause.token === 107) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 226: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; case 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + var typeAssertionExpression = node; + diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return; + } + var prevParent = parent; + parent = node; + ts.forEachChild(node, walk, walkArray); + parent = prevParent; + } + function walkArray(nodes) { + if (parent.decorators === nodes && !options.experimentalDecorators) { + 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_to_remove_this_warning)); + } + switch (parent.kind) { + case 225: + case 149: + case 148: + case 150: + case 151: + case 152: + case 183: + case 224: + case 184: + case 224: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 204: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 204); } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 175: - case 176: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 143: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 146: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + case 147: + if (nodes === parent.modifiers) { + for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 114) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } - } - if (checkTypeAnnotation(node.type)) { - return true; + return; } break; - case 225: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 178: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; case 144: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + if (nodes === parent.modifiers) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return; } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 113: - case 111: - case 112: - case 129: - case 123: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - case 114: - case 83: - case 75: - case 78: - case 116: + break; + case 178: + case 179: + case 198: + if (nodes === parent.typeArguments) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return; } + break; + } + for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { + var node = nodes_4[_b]; + walk(node); + } + } + function checkModifiers(modifiers, isConstValid) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 75: + if (isConstValid) { + continue; + } + case 113: + case 111: + case 112: + case 130: + case 123: + case 116: + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + break; + case 114: + case 83: + case 78: } } - return false; + } + function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) { + var start = nodes.pos; + return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2); + } + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } }); } @@ -49121,9 +50458,6 @@ var ts; ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } @@ -49142,14 +50476,18 @@ var ts; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); var isExternalModuleFile = ts.isExternalModule(file); + var isDtsFile = ts.isDeclarationFile(file); var imports; var moduleAugmentations; + var ambientModules; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9); + var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; + var importDecl = ts.createSynthesizedNode(234); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -49161,12 +50499,13 @@ var ts; } file.imports = imports || emptyArray; file.moduleAugmentations = moduleAugmentations || emptyArray; + file.ambientModuleNames = ambientModules || emptyArray; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 231: - case 230: - case 237: + case 234: + case 233: + case 240: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -49178,13 +50517,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 229: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { + if (isDtsFile) { + (ambientModules || (ambientModules = [])).push(moduleName.text); + } var body = node.body; if (body) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { @@ -49208,7 +50550,7 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; - if (hasExtension(fileName)) { + if (ts.hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; @@ -49269,7 +50611,7 @@ var ts; processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + if (currentNodeModulesDepth < maxNodeModuleJsDepth) { modulesWithElidedImports[file_1.path] = false; processImportedModules(file_1); } @@ -49378,23 +50720,31 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); + var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); + if (!resolution) { + continue; + } + var isFromNodeModulesSearch = resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; + var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); + var pos = ts.skipTrivia(file.text, file.imports[i].pos); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -49404,7 +50754,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -49558,7 +50907,15 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + if (options.jsxFactory) { + if (options.reactNamespace) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory")); + } + if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory)); + } + } + else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } if (!options.noEmit && !options.suppressOutputPathCheck) { @@ -49573,17 +50930,12 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) { - blockEmittingOfFile(emitFileName); - } - else { - var chain_1; - if (!options.configFilePath) { - chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); - } - chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); - blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); + var chain_1; + if (!options.configFilePath) { + chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); } + chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); } if (emitFilesSeen.contains(emitFilePath)) { blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); @@ -49596,12 +50948,31 @@ var ts; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - if (diag) { - programDiagnostics.add(diag); - } + programDiagnostics.add(diag); } } ts.createProgram = createProgram; + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: + return undefined; + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); + } + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; + } + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + } + } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; (function (ts) { @@ -49640,12 +51011,13 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + var IndentStyle; (function (IndentStyle) { IndentStyle[IndentStyle["None"] = 0] = "None"; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; + })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -49669,8 +51041,8 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -49681,8 +51053,7 @@ var ts; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; + })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { ScriptElementKind.unknown = ""; @@ -49761,37 +51132,37 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(4, true); + ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 143: - case 219: - case 170: - case 146: - case 145: - case 253: - case 254: - case 255: - case 148: + case 144: + case 222: + case 173: case 147: + case 146: + case 256: + case 257: + case 259: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 252: - return 1; - case 142: - case 223: + case 152: case 224: - case 160: - return 2; - case 222: - case 225: - return 1 | 2; + case 183: + case 184: + case 255: + return 1; + case 143: case 226: + case 227: + case 161: + return 2; + case 225: + case 228: + return 1 | 2; + case 229: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -49801,21 +51172,21 @@ var ts; else { return 4; } - case 234: - case 235: - case 230: - case 231: - case 236: case 237: + case 238: + case 233: + case 234: + case 239: + case 240: return 1 | 2 | 4; - case 256: + case 260: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236) { + if (node.parent.kind === 239) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -49837,15 +51208,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 140 && + if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 230) { + node.parent.parent.kind === 233) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 140) { + while (node.parent.kind === 141) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49856,27 +51227,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 140) { - while (root.parent && root.parent.kind === 140) { + if (root.parent.kind === 141) { + while (root.parent && root.parent.kind === 141) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 156 && !isLastClause; + return root.parent.kind === 157 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 173) { - while (root.parent && root.parent.kind === 173) { + if (root.parent.kind === 176) { + while (root.parent && root.parent.kind === 176) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 198 && root.parent.parent.kind === 254) { var decl = root.parent.parent.parent; - return (decl.kind === 222 && root.parent.parent.token === 107) || - (decl.kind === 223 && root.parent.parent.token === 84); + return (decl.kind === 225 && root.parent.parent.token === 107) || + (decl.kind === 226 && root.parent.parent.token === 84); } return false; } @@ -49884,17 +51255,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 156 || - (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 157 || + (node.parent.kind === 198 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 166; + node.kind === 167; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); + return isCallOrNewExpressionTarget(node, 178); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176); + return isCallOrNewExpressionTarget(node, 179); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -49907,7 +51278,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 218 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -49917,13 +51288,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 211 || node.parent.kind === 210) && + (node.parent.kind === 214 || node.parent.kind === 213) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 215 && + node.parent.kind === 218 && node.parent.label === node; } function isLabelName(node) { @@ -49931,15 +51302,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 140 && node.parent.right === node; + return node.parent.kind === 141 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 173 && node.parent.name === node; + return node && node.parent && node.parent.kind === 176 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 && node.parent.name === node; + return node.parent.kind === 229 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -49950,19 +51321,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 146: - case 145: - case 253: - case 255: - case 148: case 147: - case 150: + case 146: + case 256: + case 259: + case 149: + case 148: case 151: - case 226: + case 152: + case 229: return node.parent.name === node; - case 174: + case 177: return node.parent.argumentExpression === node; - case 141: + case 142: return true; } } @@ -50006,17 +51377,17 @@ var ts; return undefined; } switch (node.kind) { - case 256: + case 260: + case 149: case 148: - case 147: - case 221: - case 180: - case 150: + case 224: + case 183: case 151: - case 222: - case 223: + case 152: case 225: case 226: + case 228: + case 229: return node; } } @@ -50024,46 +51395,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256: + case 260: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226: + case 229: return ts.ScriptElementKind.moduleElement; - case 222: - case 193: + case 225: + case 196: return ts.ScriptElementKind.classElement; - case 223: return ts.ScriptElementKind.interfaceElement; - case 224: return ts.ScriptElementKind.typeElement; - case 225: return ts.ScriptElementKind.enumElement; - case 219: + case 226: return ts.ScriptElementKind.interfaceElement; + case 227: return ts.ScriptElementKind.typeElement; + case 228: return ts.ScriptElementKind.enumElement; + case 222: return getKindOfVariableDeclaration(node); - case 170: + case 173: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: return ts.ScriptElementKind.functionElement; - case 150: return ts.ScriptElementKind.memberGetAccessorElement; - case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 151: return ts.ScriptElementKind.memberGetAccessorElement; + case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 149: case 148: - case 147: return ts.ScriptElementKind.memberFunctionElement; + case 147: case 146: - case 145: return ts.ScriptElementKind.memberVariableElement; - case 154: return ts.ScriptElementKind.indexSignatureElement; - case 153: return ts.ScriptElementKind.constructSignatureElement; - case 152: return ts.ScriptElementKind.callSignatureElement; - case 149: return ts.ScriptElementKind.constructorImplementationElement; - case 142: return ts.ScriptElementKind.typeParameterElement; - case 255: return ts.ScriptElementKind.enumMemberElement; - case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 230: - case 235: - case 232: - case 239: + case 155: return ts.ScriptElementKind.indexSignatureElement; + case 154: return ts.ScriptElementKind.constructSignatureElement; + case 153: return ts.ScriptElementKind.callSignatureElement; + case 150: return ts.ScriptElementKind.constructorImplementationElement; + case 143: return ts.ScriptElementKind.typeParameterElement; + case 259: return ts.ScriptElementKind.enumMemberElement; + case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 233: + case 238: + case 235: + case 242: + case 236: return ts.ScriptElementKind.alias; - case 279: + case 283: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -50078,7 +51449,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 ? node.parent : node; + var searchNode = node.parent.kind === 170 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -50091,7 +51462,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; default: return false; } @@ -50135,41 +51506,41 @@ var ts; return false; } switch (n.kind) { - case 222: - case 223: case 225: - case 172: - case 168: - case 160: - case 200: - case 227: + case 226: case 228: - case 234: - case 238: + case 175: + case 171: + case 161: + case 203: + case 230: + case 231: + case 237: + case 241: return nodeEndsWith(n, 17, sourceFile); - case 252: + case 255: return isCompletedNode(n.block, sourceFile); - case 176: + case 179: if (!n.arguments) { return true; } - case 175: - case 179: - case 165: + case 178: + case 182: + case 166: return nodeEndsWith(n, 19, sourceFile); - case 157: case 158: + case 159: return isCompletedNode(n.type, sourceFile); - case 149: case 150: case 151: - case 221: - case 180: - case 148: - case 147: - case 153: case 152: - case 181: + case 224: + case 183: + case 149: + case 148: + case 154: + case 153: + case 184: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -50177,65 +51548,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 226: + case 229: return n.body && isCompletedNode(n.body, sourceFile); - case 204: + case 207: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203: + case 206: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 171: - case 169: case 174: - case 141: - case 162: + case 172: + case 177: + case 142: + case 163: return nodeEndsWith(n, 21, sourceFile); - case 154: + case 155: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 249: - case 250: + case 252: + case 253: return false; - case 207: - case 208: + case 210: + case 211: + case 212: case 209: - case 206: return isCompletedNode(n.statement, sourceFile); - case 205: + case 208: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 159: + case 160: return isCompletedNode(n.exprName, sourceFile); - case 183: - case 182: - case 184: - case 191: - case 192: + case 186: + case 185: + case 187: + case 194: + case 195: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177: + case 180: return isCompletedNode(n.template, sourceFile); - case 190: + case 193: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198: + case 201: return ts.nodeIsPresent(n.literal); - case 237: - case 231: + case 240: + case 234: return ts.nodeIsPresent(n.moduleSpecifier); - case 186: - return isCompletedNode(n.operand, sourceFile); - case 188: - return isCompletedNode(n.right, sourceFile); case 189: + return isCompletedNode(n.operand, sourceFile); + case 191: + return isCompletedNode(n.right, sourceFile); + case 192: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -50278,7 +51649,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 286 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 290 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -50413,7 +51784,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256); + ts.Debug.assert(startNode !== undefined || n.kind === 260); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -50458,15 +51829,15 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } + if (token.kind === 26 && token.parent.kind === 251) { + return true; + } + if (token && token.kind === 17 && token.parent.kind === 251) { + return true; + } if (token.kind === 26 && token.parent.kind === 248) { return true; } - if (token && token.kind === 17 && token.parent.kind === 248) { - return true; - } - if (token.kind === 26 && token.parent.kind === 245) { - return true; - } return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; @@ -50555,17 +51926,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 || node.kind === 175) { + if (node.kind === 157 || node.kind === 178) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { + if (ts.isFunctionLike(node) || node.kind === 225 || node.kind === 226) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 139; + return n.kind >= 0 && n.kind <= 140; } ts.isToken = isToken; function isWord(kind) { @@ -50624,18 +51995,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 || - node.kind === 172) { - if (node.parent.kind === 188 && + if (node.kind === 174 || + node.kind === 175) { + if (node.parent.kind === 191 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 209 && + if (node.parent.kind === 212 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 256 ? node.parent.parent : node.parent)) { return true; } } @@ -50666,7 +52037,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -50841,7 +52212,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 141) { + location.parent.kind === 142) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -50851,7 +52222,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 || location.parent.kind === 239) && + (location.parent.kind === 238 || location.parent.kind === 242) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -50956,89 +52327,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201: + case 204: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219: - case 146: - case 145: - return spanInVariableDeclaration(node); - case 143: - return spanInParameterDeclaration(node); - case 221: - case 148: + case 222: case 147: - case 150: - case 151: + case 146: + return spanInVariableDeclaration(node); + case 144: + return spanInParameterDeclaration(node); + case 224: case 149: - case 180: - case 181: + case 148: + case 151: + case 152: + case 150: + case 183: + case 184: return spanInFunctionDeclaration(node); - case 200: + case 203: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 227: - return spanInBlock(node); - case 252: - return spanInBlock(node.block); - case 203: - return textSpan(node.expression); - case 212: - return textSpan(node.getChildAt(0), node.expression); - case 206: - return textSpanEndingAtNextToken(node, node.expression); - case 205: - return spanInNode(node.statement); - case 218: - return textSpan(node.getChildAt(0)); - case 204: - return textSpanEndingAtNextToken(node, node.expression); - case 215: - return spanInNode(node.statement); - case 211: - case 210: - return textSpan(node.getChildAt(0), node.label); - case 207: - return spanInForStatement(node); - case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInInitializerOfForLike(node); - case 214: - return textSpanEndingAtNextToken(node, node.expression); - case 249: - case 250: - return spanInNode(node.statements[0]); - case 217: - return spanInBlock(node.tryBlock); - case 216: - return textSpan(node, node.expression); - case 236: - return textSpan(node, node.expression); case 230: + return spanInBlock(node); + case 255: + return spanInBlock(node.block); + case 206: + return textSpan(node.expression); + case 215: + return textSpan(node.getChildAt(0), node.expression); + case 209: + return textSpanEndingAtNextToken(node, node.expression); + case 208: + return spanInNode(node.statement); + case 221: + return textSpan(node.getChildAt(0)); + case 207: + return textSpanEndingAtNextToken(node, node.expression); + case 218: + return spanInNode(node.statement); + case 214: + case 213: + return textSpan(node.getChildAt(0), node.label); + case 210: + return spanInForStatement(node); + case 211: + return textSpanEndingAtNextToken(node, node.expression); + case 212: + return spanInInitializerOfForLike(node); + case 217: + return textSpanEndingAtNextToken(node, node.expression); + case 252: + case 253: + return spanInNode(node.statements[0]); + case 220: + return spanInBlock(node.tryBlock); + case 219: + return textSpan(node, node.expression); + case 239: + return textSpan(node, node.expression); + case 233: return textSpan(node, node.moduleReference); - case 231: + case 234: return textSpan(node, node.moduleSpecifier); - case 237: + case 240: return textSpan(node, node.moduleSpecifier); - case 226: + case 229: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 222: case 225: - case 255: - case 170: + case 228: + case 259: + case 173: return textSpan(node); - case 213: + case 216: return spanInNode(node.statement); - case 144: + case 145: return spanInNodeArray(node.parent.decorators); - case 168: - case 169: + case 171: + case 172: return spanInBindingPattern(node); - case 223: - case 224: + case 226: + case 227: return undefined; case 24: case 1: @@ -51066,20 +52437,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 139: + case 140: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 192 || - node.kind === 253 || - node.kind === 254) && + node.kind == 195 || + node.kind === 256 || + node.kind === 257) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188) { + if (node.kind === 191) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -51094,38 +52465,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205: + case 208: return spanInPreviousNode(node); - case 144: + case 145: return spanInNode(node.parent); - case 207: - case 209: + case 210: + case 212: return textSpan(node); - case 188: + case 191: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 181: + case 184: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 253 && + if (node.parent.kind === 256 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 178 && node.parent.type === node) { + if (node.parent.kind === 181 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 219 || - node.parent.kind === 143)) { + if ((node.parent.kind === 222 || + node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -51133,7 +52504,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188) { + if (node.parent.kind === 191) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -51154,7 +52525,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 208) { + if (variableDeclaration.parent.parent.kind === 211) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -51162,7 +52533,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 209) { + variableDeclaration.parent.parent.kind === 212) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -51194,7 +52565,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); + (functionDeclaration.parent.kind === 225 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -51214,22 +52585,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226: + case 229: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 206: - case 204: - case 208: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 207: case 209: + case 207: + case 211: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 210: + case 212: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 220) { + if (forLikeStatement.initializer.kind === 223) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -51251,62 +52622,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 197 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 170) { + if (bindingPattern.parent.kind === 173) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 169 && node.kind !== 168); - var elements = node.kind === 171 ? + ts.Debug.assert(node.kind !== 172 && node.kind !== 171); + var elements = node.kind === 174 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 197 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 188 ? node.parent : node); + return textSpan(node.parent.kind === 191 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225: + case 228: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 222: + case 225: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 228: + case 231: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227: + case 230: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } + case 228: case 225: - case 222: return textSpan(node); - case 200: + case 203: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 252: + case 255: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228: + case 231: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168: + case 171: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51319,7 +52690,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169: + case 172: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51331,33 +52702,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 || - node.parent.kind === 175 || - node.parent.kind === 176) { + if (node.parent.kind === 208 || + node.parent.kind === 178 || + node.parent.kind === 179) { return spanInPreviousNode(node); } - if (node.parent.kind === 179) { + if (node.parent.kind === 182) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 180: - case 221: - case 181: - case 148: - case 147: - case 150: - case 151: + case 183: + case 224: + case 184: case 149: - case 206: - case 205: - case 207: + case 148: + case 151: + case 152: + case 150: case 209: - case 175: - case 176: + case 208: + case 210: + case 212: + case 178: case 179: + case 182: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -51365,26 +52736,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 || - node.parent.kind === 143) { + node.parent.kind === 256 || + node.parent.kind === 144) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178) { + if (node.parent.kind === 181) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205) { + if (node.parent.kind === 208) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 212) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -51397,7 +52768,7 @@ var ts; var ts; (function (ts) { function createClassifier() { - var scanner = ts.createScanner(4, false); + var scanner = ts.createScanner(5, false); var noRegexTable = []; noRegexTable[70] = true; noRegexTable[9] = true; @@ -51415,7 +52786,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 132 || + keyword2 === 133 || keyword2 === 122 || keyword2 === 114) { return true; @@ -51531,10 +52902,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 133 || - token === 131 || + token === 134 || + token === 132 || token === 121 || - token === 134) { + token === 135) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -51689,7 +53060,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 139; + return token >= 71 && token <= 140; } function classFromKind(token) { if (isKeyword(token)) { @@ -51735,10 +53106,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { + case 229: + case 225: case 226: - case 222: - case 223: - case 221: + case 224: cancellationToken.throwIfCancellationRequested(); } } @@ -51782,7 +53153,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 && + return declaration.kind === 229 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -51854,8 +53225,8 @@ var ts; function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(5, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(5, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -51923,16 +53294,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 275: + case 279: processJSDocParameterTag(tag); break; - case 278: + case 282: processJSDocTemplateTag(tag); break; - case 277: + case 281: processElement(tag.typeExpression); break; - case 276: + case 280: processElement(tag.typeExpression); break; } @@ -52013,22 +53384,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244: + case 247: if (token.parent.tagName === token) { return 19; } break; - case 245: + case 248: if (token.parent.tagName === token) { return 20; } break; - case 243: + case 246: if (token.parent.tagName === token) { return 21; } break; - case 246: + case 249: if (token.parent.name === token) { return 22; } @@ -52048,17 +53419,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 219 || - token.parent.kind === 146 || - token.parent.kind === 143 || - token.parent.kind === 246) { + if (token.parent.kind === 222 || + token.parent.kind === 147 || + token.parent.kind === 144 || + token.parent.kind === 249) { return 5; } } - if (token.parent.kind === 188 || - token.parent.kind === 186 || - token.parent.kind === 187 || - token.parent.kind === 189) { + if (token.parent.kind === 191 || + token.parent.kind === 189 || + token.parent.kind === 190 || + token.parent.kind === 192) { return 5; } } @@ -52068,7 +53439,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 246 ? 24 : 6; + return token.parent.kind === 249 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -52082,32 +53453,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 222: + case 225: if (token.parent.name === token) { return 11; } return; - case 142: + case 143: if (token.parent.name === token) { return 15; } return; - case 223: + case 226: if (token.parent.name === token) { return 13; } return; - case 225: + case 228: if (token.parent.name === token) { return 12; } return; - case 226: + case 229: if (token.parent.name === token) { return 14; } return; - case 143: + case 144: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -52162,7 +53533,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 245) { + location.parent && location.parent.kind === 248) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -52184,13 +53555,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { + for (var name_43 in nameTable) { + if (nameTable[name_43] === position) { continue; } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); + if (!uniqueNames[name_43]) { + uniqueNames[name_43] = name_43; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_43), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -52240,15 +53611,15 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && - node.parent.parent.kind === 172 && + if (node.parent.kind === 256 && + node.parent.parent.kind === 175 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 234 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -52577,8 +53948,8 @@ var ts; } catch (e) { } if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; + for (var _b = 0, typeRoots_3 = typeRoots; _b < typeRoots_3.length; _b++) { + var root = typeRoots_3[_b]; getCompletionEntriesFromDirectories(host, root, span, result); } } @@ -52612,11 +53983,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_15 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_15) { break; } - currentDir = parent_16; + currentDir = parent_15; } else { break; @@ -52748,9 +54119,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277: - case 275: - case 276: + case 281: + case 279: + case 280: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -52785,13 +54156,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_16 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_17.kind === 173) { + if (parent_16.kind === 176) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140) { + else if (parent_16.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -52804,7 +54175,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 248) { isStartingCloseTag = true; location = contextToken; } @@ -52849,7 +54220,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 140 || node.kind === 173) { + if (node.kind === 70 || node.kind === 141 || node.kind === 176) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -52895,7 +54266,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { + if ((jsxContainer.kind === 246) || (jsxContainer.kind === 247)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -52916,9 +54287,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 || - scopeNode.kind === 190 || - scopeNode.kind === 248 || + scopeNode.kind === 260 || + scopeNode.kind === 193 || + scopeNode.kind === 251 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -52946,11 +54317,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 244) { + if (contextToken.parent.kind === 247) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242; + if (contextToken.parent.kind === 248 || contextToken.parent.kind === 246) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 245; } } return false; @@ -52960,40 +54331,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 - || containingNodeKind === 171 - || containingNodeKind === 188 - || containingNodeKind === 157; - case 18: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 + return containingNodeKind === 178 + || containingNodeKind === 150 || containingNodeKind === 179 - || containingNodeKind === 165; + || containingNodeKind === 174 + || containingNodeKind === 191 + || containingNodeKind === 158; + case 18: + return containingNodeKind === 178 + || containingNodeKind === 150 + || containingNodeKind === 179 + || containingNodeKind === 182 + || containingNodeKind === 166; case 20: - return containingNodeKind === 171 - || containingNodeKind === 154 - || containingNodeKind === 141; - case 126: + return containingNodeKind === 174 + || containingNodeKind === 155 + || containingNodeKind === 142; case 127: + case 128: return true; case 22: - return containingNodeKind === 226; + return containingNodeKind === 229; case 16: - return containingNodeKind === 222; + return containingNodeKind === 225; case 57: - return containingNodeKind === 219 - || containingNodeKind === 188; + return containingNodeKind === 222 + || containingNodeKind === 191; case 13: - return containingNodeKind === 190; + return containingNodeKind === 193; case 14: - return containingNodeKind === 198; + return containingNodeKind === 201; case 113: case 111: case 112: - return containingNodeKind === 146; + return containingNodeKind === 147; } switch (previousToken.getText()) { case "public": @@ -53024,22 +54395,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172) { + if (objectLikeContainer.kind === 175) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168) { + else if (objectLikeContainer.kind === 171) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 143) { + if (!canGetType && rootDeclaration.kind === 144) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { + else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -53065,9 +54436,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 ? - 231 : - 237; + var declarationKind = namedImportsOrExports.kind === 237 ? + 234 : + 240; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -53088,9 +54459,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { - return parent_18; + var parent_17 = contextToken.parent; + if (parent_17 && (parent_17.kind === 175 || parent_17.kind === 171)) { + return parent_17; } break; } @@ -53103,8 +54474,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 234: - case 238: + case 237: + case 241: return contextToken.parent; } } @@ -53113,34 +54484,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_18 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 246: - case 247: - if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { - return parent_19; + case 249: + case 250: + if (parent_18 && (parent_18.kind === 246 || parent_18.kind === 247)) { + return parent_18; } - else if (parent_19.kind === 246) { - return parent_19.parent; + else if (parent_18.kind === 249) { + return parent_18.parent; } break; case 9: - if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { - return parent_19.parent; + if (parent_18 && ((parent_18.kind === 249) || (parent_18.kind === 250))) { + return parent_18.parent; } break; case 17: - if (parent_19 && - parent_19.kind === 248 && - parent_19.parent && - (parent_19.parent.kind === 246)) { - return parent_19.parent.parent; + if (parent_18 && + parent_18.kind === 251 && + parent_18.parent && + (parent_18.parent.kind === 249)) { + return parent_18.parent.parent; } - if (parent_19 && parent_19.kind === 247) { - return parent_19.parent; + if (parent_18 && parent_18.kind === 250) { + return parent_18.parent; } break; } @@ -53149,16 +54520,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180: - case 181: - case 221: + case 183: + case 184: + case 224: + case 149: case 148: - case 147: - case 150: case 151: case 152: case 153: case 154: + case 155: return true; } return false; @@ -53167,66 +54538,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 219 || - containingNodeKind === 220 || - containingNodeKind === 201 || - containingNodeKind === 225 || - isFunction(containingNodeKind) || - containingNodeKind === 222 || - containingNodeKind === 193 || + return containingNodeKind === 222 || containingNodeKind === 223 || - containingNodeKind === 169 || - containingNodeKind === 224; + containingNodeKind === 204 || + containingNodeKind === 228 || + isFunction(containingNodeKind) || + containingNodeKind === 225 || + containingNodeKind === 196 || + containingNodeKind === 226 || + containingNodeKind === 172 || + containingNodeKind === 227; case 22: - return containingNodeKind === 169; + return containingNodeKind === 172; case 55: - return containingNodeKind === 170; + return containingNodeKind === 173; case 20: - return containingNodeKind === 169; + return containingNodeKind === 172; case 18: - return containingNodeKind === 252 || + return containingNodeKind === 255 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 225 || - containingNodeKind === 223 || - containingNodeKind === 160; + return containingNodeKind === 228 || + containingNodeKind === 226 || + containingNodeKind === 161; case 24: - return containingNodeKind === 145 && + return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 223 || - contextToken.parent.parent.kind === 160); + (contextToken.parent.parent.kind === 226 || + contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 224 || + return containingNodeKind === 225 || + containingNodeKind === 196 || + containingNodeKind === 226 || + containingNodeKind === 227 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 146; + return containingNodeKind === 147; case 23: - return containingNodeKind === 143 || + return containingNodeKind === 144 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 169); + contextToken.parent.parent.kind === 172); case 113: case 111: case 112: - return containingNodeKind === 143; + return containingNodeKind === 144; case 117: - return containingNodeKind === 235 || - containingNodeKind === 239 || - containingNodeKind === 233; + return containingNodeKind === 238 || + containingNodeKind === 242 || + containingNodeKind === 236; case 74: case 82: case 108: case 88: case 103: case 124: - case 132: + case 133: case 90: case 109: case 75: case 115: - case 135: + case 136: return true; } switch (contextToken.getText()) { @@ -53263,8 +54634,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.text] = true; + var name_44 = element.propertyName || element.name; + existingImportsOrExports[name_44.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -53278,17 +54649,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 253 && - m.kind !== 254 && - m.kind !== 170 && - m.kind !== 148) { + if (m.kind !== 256 && + m.kind !== 257 && + m.kind !== 173 && + m.kind !== 149 && + m.kind !== 151 && + m.kind !== 152) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 170 && m.propertyName) { + if (m.kind === 173 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -53307,7 +54680,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246) { + if (attr.kind === 249) { seenNames[attr.name.text] = true; } } @@ -53340,7 +54713,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 139; i++) { + for (var i = 71; i <= 140; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -53404,7 +54777,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 70 || node.kind === 98 || - node.kind === 166 || + node.kind === 167 || node.kind === 96 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { @@ -53456,75 +54829,75 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 204)) { + if (hasKind(node.parent, 207)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 212)) { + if (hasKind(node.parent, 215)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 219)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 217)) { + if (hasKind(parent(parent(node)), 220)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 217)) { + if (hasKind(parent(node), 220)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 214)) { + if (hasKind(node.parent, 217)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 214)) { + if (hasKind(parent(parent(parent(node))), 217)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { + if (hasKind(node.parent, 214) || hasKind(node.parent, 213)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 207) || - hasKind(node.parent, 208) || - hasKind(node.parent, 209)) { + if (hasKind(node.parent, 210) || + hasKind(node.parent, 211) || + hasKind(node.parent, 212)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { + if (hasKind(node.parent, 209) || hasKind(node.parent, 208)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 122: - if (hasKind(node.parent, 149)) { + if (hasKind(node.parent, 150)) { return getConstructorOccurrences(node.parent); } break; case 124: - case 132: - if (hasKind(node.parent, 150) || hasKind(node.parent, 151)) { + case 133: + if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 201)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 204)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -53536,10 +54909,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216) { + if (node.kind === 219) { statementAccumulator.push(node); } - else if (node.kind === 217) { + else if (node.kind === 220) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -53559,17 +54932,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { - return parent_20; + var parent_19 = child.parent; + if (ts.isFunctionBlock(parent_19) || parent_19.kind === 260) { + return parent_19; } - if (parent_20.kind === 217) { - var tryStatement = parent_20; + if (parent_19.kind === 220) { + var tryStatement = parent_19; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_19; } return undefined; } @@ -53578,7 +54951,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 || node.kind === 210) { + if (node.kind === 214 || node.kind === 213) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -53593,15 +54966,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 214: - if (statement.kind === 210) { + case 217: + if (statement.kind === 213) { continue; } - case 207: - case 208: + case 210: + case 211: + case 212: case 209: - case 206: - case 205: + case 208: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -53618,24 +54991,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 222 || - container.kind === 193 || - (declaration.kind === 143 && hasKind(container, 149)))) { + if (!(container.kind === 225 || + container.kind === 196 || + (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 222 || container.kind === 193)) { + if (!(container.kind === 225 || container.kind === 196)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 227 || container.kind === 256)) { + if (!(container.kind === 230 || container.kind === 260)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 222 || declaration.kind === 222)) { + if (!(container.kind === 225 || declaration.kind === 225)) { return undefined; } } @@ -53646,8 +55019,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227: - case 256: + case 230: + case 260: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -53655,15 +55028,15 @@ var ts; nodes = container.statements; } break; - case 149: + case 150: nodes = container.parameters.concat(container.parent.members); break; - case 222: - case 193: + case 225: + case 196: nodes = container.members; if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 149 && member; + return member.kind === 150 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -53716,13 +55089,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 150); tryPushAccessorKeyword(accessorDeclaration.symbol, 151); + tryPushAccessorKeyword(accessorDeclaration.symbol, 152); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 133); }); } } } @@ -53739,7 +55112,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 205) { + if (loopNode.kind === 208) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -53760,13 +55133,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207: + case 210: + case 211: + case 212: case 208: case 209: - case 205: - case 206: return getLoopBreakContinueOccurrences(owner); - case 214: + case 217: return getSwitchCaseDefaultOccurrences(owner); } } @@ -53816,7 +55189,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 200))) { + if (!(func && hasKind(func.body, 203))) { return undefined; } var keywords = []; @@ -53830,7 +55203,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 207) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -53841,7 +55214,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204)) { + if (!hasKind(ifStatement.elseStatement, 207)) { break; } ifStatement = ifStatement.elseStatement; @@ -53876,7 +55249,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 218; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -54080,16 +55453,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 232); + var defaultImport = ts.getDeclarationOfKind(symbol, 235); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || - declaration.kind === 239) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 238 || + declaration.kind === 242) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 235 ? + return importOrExportSpecifier.kind === 238 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -54104,14 +55477,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 173); return bindingElement && - bindingElement.parent.kind === 168 && + bindingElement.parent.kind === 171 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 173); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -54127,13 +55500,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { + if (valueDeclaration && (valueDeclaration.kind === 183 || valueDeclaration.kind === 196)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 222); + return ts.getAncestor(privateDeclaration, 225); } } if (symbol.flags & 8388608) { @@ -54157,7 +55530,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 256 && !ts.isExternalModule(container)) { + if (container.kind === 260 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -54179,8 +55552,8 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -54324,14 +55697,14 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149); + ts.Debug.assert(decl.kind === 150); var ctrKeyword = decl.getChildAt(0); ts.Debug.assert(ctrKeyword.kind === 122); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 148) { + if (decl && decl.kind === 149) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 98, function (thisKeyword) { @@ -54353,7 +55726,7 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149); + ts.Debug.assert(decl.kind === 150); var body = decl.body; if (body) { forEachDescendantOfKind(body, 96, function (node) { @@ -54394,7 +55767,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 254) { + if (refNode.parent.kind === 257) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -54404,24 +55777,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_21 = containingTypeReference.parent; - if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); + var parent_20 = containingTypeReference.parent; + if (ts.isVariableLike(parent_20) && parent_20.type === containingTypeReference && parent_20.initializer && isImplementationExpression(parent_20.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_20.initializer)); } - else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 200) { - ts.forEachReturnStatement(parent_21.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_20) && parent_20.type === containingTypeReference && parent_20.body) { + if (parent_20.body.kind === 203) { + ts.forEachReturnStatement(parent_20.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_21.body)) { - maybeAdd(getReferenceEntryFromNode(parent_21.body)); + else if (isImplementationExpression(parent_20.body)) { + maybeAdd(getReferenceEntryFromNode(parent_20.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_20) && isImplementationExpression(parent_20.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_20.expression)); } } } @@ -54456,26 +55829,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 - && node.parent.kind === 251 + if (node.kind === 198 + && node.parent.kind === 254 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 || node.kind === 173) { + else if (node.kind === 70 || node.kind === 176) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 179) { + if (node.kind === 182) { return isImplementationExpression(node.expression); } - return node.kind === 181 || - node.kind === 180 || - node.kind === 172 || - node.kind === 193 || - node.kind === 171; + return node.kind === 184 || + node.kind === 183 || + node.kind === 175 || + node.kind === 196 || + node.kind === 174; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -54504,7 +55877,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223) { + else if (declaration.kind === 226) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -54531,13 +55904,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 146: - case 145: - case 148: case 147: + case 146: case 149: + case 148: case 150: case 151: + case 152: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -54565,32 +55938,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 149: case 148: - case 147: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 147: case 146: - case 145: - case 149: case 150: case 151: + case 152: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 256: + case 260: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 221: - case 180: + case 224: + case 183: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256) { + if (searchSpaceNode.kind === 260) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -54624,26 +55997,26 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 180: - case 221: + case 183: + case 224: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 149: case 148: - case 147: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 193: - case 222: + case 196: + case 225: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 256: - if (container.kind === 256 && !ts.isExternalModule(container)) { + case 260: + if (container.kind === 260 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -54692,7 +56065,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 257) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -54711,7 +56084,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -54742,7 +56115,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223) { + else if (declaration.kind === 226) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -54805,7 +56178,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 141) { + if (node.name.kind === 142) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -54874,7 +56247,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219) { + else if (node.kind === 222) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -54884,18 +56257,18 @@ var ts; } else { switch (node.kind) { - case 222: - case 193: case 225: - case 226: + case 196: + case 228: + case 229: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { - ts.Debug.assert(node.parent.kind === 220); + if (node.parent && node.parent.parent && node.parent.parent.kind === 204) { + ts.Debug.assert(node.parent.kind === 223); return node.parent.parent; } } @@ -54933,10 +56306,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 || parent.kind === 186) { + if (parent.kind === 190 || parent.kind === 189) { return true; } - else if (parent.kind === 188 && parent.left === node) { + else if (parent.kind === 191 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -54955,7 +56328,7 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 141) { + if (node.parent.kind === 142) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } case 70: @@ -54965,11 +56338,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253: - case 254: - case 148: - case 150: + case 256: + case 257: + case 149: case 151: + case 152: return true; } return false; @@ -55028,11 +56401,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { + (declaration.kind === 238 && declaration.parent && declaration.parent.kind === 237))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 254) { + if (node.parent.kind === 257) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -55109,8 +56482,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 149) || - (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { + if ((selectConstructors && d.kind === 150) || + (!selectConstructors && (d.kind === 224 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -55186,7 +56559,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 254) { + if (node.parent.kind === 257) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -55311,16 +56684,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221: - case 148: + case 224: case 149: - case 222: - case 201: + case 150: + case 225: + case 204: break findOwner; - case 256: + case 260: return undefined; - case 226: - if (commentOwner.parent.kind === 226) { + case 229: + if (commentOwner.parent.kind === 229) { return undefined; } break findOwner; @@ -55354,7 +56727,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201) { + if (commentOwner.kind === 204) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -55364,17 +56737,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179) { + while (rightHandSide.kind === 182) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180: - case 181: + case 183: + case 184: return rightHandSide.parameters; - case 193: + case 196: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149) { + if (member.kind === 150) { return member.parameters; } } @@ -55397,10 +56770,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_49 in nameToDeclarations) { - var declarations = nameToDeclarations[name_49]; + for (var name_45 in nameToDeclarations) { + var declarations = nameToDeclarations[name_45]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_45); if (!matches) { continue; } @@ -55411,21 +56784,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_49); + matches = patternMatcher.getMatches(containers, name_45); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_45, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { + if (decl.kind === 235 || decl.kind === 238 || decl.kind === 233) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -55466,7 +56839,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 141) { + else if (declaration.name.kind === 142) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -55483,7 +56856,7 @@ var ts; } return true; } - if (expression.kind === 173) { + if (expression.kind === 176) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -55494,7 +56867,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 141) { + if (declaration.name.kind === 142) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -55626,7 +56999,7 @@ var ts; return; } switch (node.kind) { - case 149: + case 150: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -55636,28 +57009,28 @@ var ts; } } break; - case 148: - case 150: + case 149: case 151: - case 147: + case 152: + case 148: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 147: case 146: - case 145: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 232: + case 235: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 236) { addLeafNode(namedBindings); } else { @@ -55668,12 +57041,12 @@ var ts; } } break; - case 170: - case 219: + case 173: + case 222: var decl = node; - var name_50 = decl.name; - if (ts.isBindingPattern(name_50)) { - addChildrenRecursively(name_50); + var name_46 = decl.name; + if (ts.isBindingPattern(name_46)) { + addChildrenRecursively(name_46); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -55682,12 +57055,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: addNodeWithRecursiveChild(node, node.body); break; - case 225: + case 228: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -55697,9 +57070,9 @@ var ts; } endNode(); break; - case 222: - case 193: - case 223: + case 225: + case 196: + case 226: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -55707,21 +57080,21 @@ var ts; } endNode(); break; - case 226: + case 229: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239: - case 230: - case 154: - case 152: + case 242: + case 233: + case 155: case 153: - case 224: + case 154: + case 227: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279) { + if (tag.kind === 283) { addLeafNode(tag); } }); @@ -55769,12 +57142,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 229 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 226) { + if (a.body.kind !== 229) { return true; } return areSameModule(a.body, b.body); @@ -55825,7 +57198,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 226) { + if (node.kind === 229) { return getModuleName(node); } var decl = node; @@ -55833,18 +57206,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180: - case 181: - case 193: + case 183: + case 184: + case 196: return getFunctionOrClassName(node); - case 279: + case 283: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226) { + if (node.kind === 229) { return getModuleName(node); } var name = node.name; @@ -55855,29 +57228,29 @@ var ts; } } switch (node.kind) { - case 256: + case 260: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 181: - case 221: - case 180: - case 222: - case 193: + case 184: + case 224: + case 183: + case 225: + case 196: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 149: + case 150: return "constructor"; - case 153: - return "new()"; - case 152: - return "()"; case 154: + return "new()"; + case 153: + return "()"; + case 155: return "[]"; - case 279: + case 283: return getJSDocTypedefTagName(node); default: return ""; @@ -55889,7 +57262,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 204) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -55917,24 +57290,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222: - case 193: case 225: - case 223: + case 196: + case 228: case 226: - case 256: - case 224: - case 279: + case 229: + case 260: + case 227: + case 283: return true; - case 149: - case 148: case 150: + case 149: case 151: - case 219: + case 152: + case 222: return hasSomeImportantChild(item); - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: return isTopLevelFunctionDeclaration(item); default: return false; @@ -55944,10 +57317,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227: - case 256: - case 148: + case 230: + case 260: case 149: + case 150: return true; default: return hasSomeImportantChild(item); @@ -55956,7 +57329,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 && childKind !== 170; + return childKind !== 222 && childKind !== 173; }); } } @@ -56011,20 +57384,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 229) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 229 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 141; + return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 256 + return node.kind === 260 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -56032,14 +57405,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 219) { + else if (node.parent.kind === 222) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 && + else if (node.parent.kind === 191 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 && node.parent.name) { + else if (node.parent.kind === 256 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -56050,7 +57423,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 || node.kind === 181 || node.kind === 193; + return node.kind === 183 || node.kind === 184 || node.kind === 196; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -56123,7 +57496,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181; + return ts.isFunctionBlock(node) && node.parent.kind !== 184; } var depth = 0; var maxDepth = 20; @@ -56135,26 +57508,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200: + case 203: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_21 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_22.kind === 205 || - parent_22.kind === 208 || - parent_22.kind === 209 || - parent_22.kind === 207 || - parent_22.kind === 204 || - parent_22.kind === 206 || - parent_22.kind === 213 || - parent_22.kind === 252) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + if (parent_21.kind === 208 || + parent_21.kind === 211 || + parent_21.kind === 212 || + parent_21.kind === 210 || + parent_21.kind === 207 || + parent_21.kind === 209 || + parent_21.kind === 216 || + parent_21.kind === 255) { + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217) { - var tryStatement = parent_22; + if (parent_21.kind === 220) { + var tryStatement = parent_21; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -56174,23 +57547,23 @@ var ts; }); break; } - case 227: { + case 230: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 222: - case 223: case 225: - case 172: - case 228: { + case 226: + case 228: + case 175: + case 231: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171: + case 174: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -56208,13 +57581,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var PatternMatchKind; (function (PatternMatchKind) { PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; + })(PatternMatchKind = ts.PatternMatchKind || (ts.PatternMatchKind = {})); function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { return { kind: kind, @@ -56435,7 +57808,7 @@ var ts; if (ch >= 65 && ch <= 90) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 5)) { return false; } var str = String.fromCharCode(ch); @@ -56445,7 +57818,7 @@ var ts; if (ch >= 97 && ch <= 122) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 5)) { return false; } var str = String.fromCharCode(ch); @@ -56681,7 +58054,7 @@ var ts; var token = ts.scanner.getToken(); if (token === 123) { token = nextToken(); - if (token === 126) { + if (token === 127) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -56702,7 +58075,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56728,7 +58101,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56742,7 +58115,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56768,7 +58141,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56778,7 +58151,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56802,7 +58175,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 130) { + if (token === 131) { token = nextToken(); if (token === 18) { token = nextToken(); @@ -57021,14 +58394,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175) { + if (argumentInfo.invocation.kind !== 178) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 173 + : expression.kind === 176 ? expression.name : undefined; if (!name || !name.text) { @@ -57057,7 +58430,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 || node.parent.kind === 176) { + if (node.parent.kind === 178 || node.parent.kind === 179) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -57089,23 +58462,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 177) { + else if (node.kind === 12 && node.parent.kind === 180) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 177) { + else if (node.kind === 13 && node.parent.parent.kind === 180) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 193); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { + else if (node.parent.kind === 201 && node.parent.parent.parent.kind === 180) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 193); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -57169,7 +58542,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 190) { + if (template.kind === 193) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -57178,7 +58551,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 256; n = n.parent) { + for (var n = node; n.kind !== 260; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -57228,7 +58601,9 @@ var ts; if (callTargetDisplayParts) { ts.addRange(prefixDisplayParts, callTargetDisplayParts); } + var isVariadic; if (isTypeParameterList) { + isVariadic = false; prefixDisplayParts.push(ts.punctuationPart(26)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; @@ -57239,6 +58614,7 @@ var ts; ts.addRange(suffixDisplayParts, parameterParts); } else { + isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); @@ -57253,7 +58629,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], @@ -57307,7 +58683,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 193) ? + return ts.getDeclarationOfKind(symbol, 196) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -57407,14 +58783,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 173) { + if (location.parent && location.parent.kind === 176) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression = void 0; - if (location.kind === 175 || location.kind === 176) { + if (location.kind === 178 || location.kind === 179) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -57426,7 +58802,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpression.kind === 179 || callExpression.expression.kind === 96; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -57474,21 +58850,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 149)) { + (location.kind === 122 && location.parent.kind === 150)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 149) { + if (functionDeclaration.kind === 150) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -57497,7 +58873,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193)) { + if (ts.getDeclarationOfKind(symbol, 196)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -57516,7 +58892,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -57537,9 +58913,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226); + var declaration = ts.getDeclarationOfKind(symbol, 229); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; - displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); + displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -57558,23 +58934,23 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 142); + var declaration = ts.getDeclarationOfKind(symbol, 143); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 153) { + if (declaration.kind === 154) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 152 && declaration.name) { + else if (declaration.kind !== 153 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -57585,7 +58961,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255) { + if (declaration.kind === 259) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -57597,10 +58973,10 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229) { + if (symbol.declarations[0].kind === 232) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127)); + displayParts.push(ts.keywordPart(128)); } else { displayParts.push(ts.keywordPart(90)); @@ -57608,13 +58984,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230) { + if (declaration.kind === 233) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.keywordPart(131)); displayParts.push(ts.punctuationPart(18)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(19)); @@ -57676,10 +59052,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 260; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 188) { + if (!declaration.parent || declaration.parent.kind !== 191) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -57754,14 +59130,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 180) { + if (declaration.kind === 183) { return true; } - if (declaration.kind !== 219 && declaration.kind !== 221) { + if (declaration.kind !== 222 && declaration.kind !== 224) { return false; } - for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 227) { + for (var parent_22 = declaration.parent; !ts.isFunctionBlock(parent_22); parent_22 = parent_22.parent) { + if (parent_22.kind === 260 || parent_22.kind === 230) { return false; } } @@ -57845,7 +59221,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -57861,7 +59237,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_4(opt); } return options; } @@ -57870,8 +59246,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(4, false, 0); - var jsxScanner = ts.createScanner(4, false, 1); + var standardScanner = ts.createScanner(5, false, 0); + var jsxScanner = ts.createScanner(5, false, 1); var scanner; function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); @@ -57952,10 +59328,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 249: + case 247: + case 248: case 246: - case 244: - case 245: - case 243: return node.kind === 70; } } @@ -58330,13 +59706,13 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126, 130]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 126, 127, 111, 113, 112, 132, 114, 135, 137]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 137])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -58350,7 +59726,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -58455,43 +59831,43 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_51 in o) { - if (o[name_51] === rule) { - return name_51; + for (var name_47 in o) { + if (o[name_47] === rule) { + return name_47; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 207; + return context.contextNode.kind === 210; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188: - case 189: - case 196: - case 239: - case 235: - case 155: - case 163: + case 191: + case 192: + case 199: + case 242: + case 238: + case 156: case 164: + case 165: return true; - case 170: - case 224: - case 230: - case 219: - case 143: - case 255: + case 173: + case 227: + case 233: + case 222: + case 144: + case 259: + case 147: case 146: - case 145: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 208: + case 211: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 209: - return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; + case 212: + return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; }; @@ -58499,7 +59875,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 192; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -58524,90 +59900,90 @@ var ts; return true; } switch (node.kind) { - case 200: - case 228: - case 172: - case 227: + case 203: + case 231: + case 175: + case 230: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221: + case 224: + case 149: case 148: - case 147: - case 150: case 151: case 152: - case 180: - case 149: - case 181: - case 223: + case 153: + case 183: + case 150: + case 184: + case 226: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 || context.contextNode.kind === 180; + return context.contextNode.kind === 224 || context.contextNode.kind === 183; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 222: - case 193: - case 223: case 225: - case 160: + case 196: case 226: - case 237: - case 238: - case 231: + case 228: + case 161: + case 229: + case 240: + case 241: case 234: + case 237: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 222: - case 226: case 225: - case 200: - case 252: - case 227: - case 214: + case 229: + case 228: + case 203: + case 255: + case 230: + case 217: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 204: - case 214: case 207: - case 208: - case 209: - case 206: case 217: - case 205: - case 213: - case 252: + case 210: + case 211: + case 212: + case 209: + case 220: + case 208: + case 216: + case 255: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172; - }; - Rules.IsFunctionCallContext = function (context) { return context.contextNode.kind === 175; }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 178; + }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 179; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -58619,25 +59995,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 184; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242; + return context.contextNode.kind !== 245; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 251; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246; + return context.nextTokenParent.kind === 249; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246; + return context.contextNode.kind === 249; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243; + return context.contextNode.kind === 246; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -58652,41 +60028,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 144; + return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 220 && + return context.currentTokenParent.kind === 223 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 226; + return context.contextNode.kind === 229; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 160; + return context.contextNode.kind === 161; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 156: - case 178: - case 222: - case 193: - case 223: - case 221: - case 180: + case 157: case 181: + case 225: + case 196: + case 226: + case 224: + case 183: + case 184: + case 149: case 148: - case 147: - case 152: case 153: - case 175: - case 176: - case 195: + case 154: + case 178: + case 179: + case 198: return true; default: return false; @@ -58697,13 +60073,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178; + return context.contextNode.kind === 181; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 187; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 194 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -58725,7 +60101,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 139 + 1; + this.mapRowLength = 140 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -58738,7 +60114,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -58775,6 +60151,7 @@ var ts; formatting.RulesMap = RulesMap; var MaskBitSize = 5; var Mask = 0x1f; + var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; @@ -58782,8 +60159,7 @@ var ts; RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; + })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); var RulesBucketConstructionState = (function () { function RulesBucketConstructionState() { this.rulesInsertionIndexBitmap = 0; @@ -58902,7 +60278,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 139; token++) { + for (var token = 0; token <= 140; token++) { result.push(token); } return result; @@ -58946,9 +60322,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 139); + TokenRange.Keywords = TokenRange.FromRange(71, 140); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -58956,7 +60332,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -59164,17 +60540,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 222: - case 223: - return ts.rangeContainsRange(parent.members, node); + case 225: case 226: + return ts.rangeContainsRange(parent.members, node); + case 229: var body = parent.body; - return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); - case 256: - case 200: - case 227: + return body && body.kind === 230 && ts.rangeContainsRange(body.statements, node); + case 260: + case 203: + case 230: return ts.rangeContainsRange(parent.statements, node); - case 252: + case 255: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -59330,18 +60706,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 222: return 74; - case 223: return 108; - case 221: return 88; - case 225: return 225; - case 150: return 124; - case 151: return 132; - case 148: + case 225: return 74; + case 226: return 108; + case 224: return 88; + case 228: return 228; + case 151: return 124; + case 152: return 133; + case 149: if (node.asteriskToken) { return 38; } - case 146: - case 143: + case 147: + case 144: return node.name.kind; } } @@ -59457,11 +60833,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 174 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -59765,12 +61141,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 150: + case 224: + case 183: case 149: - case 221: - case 180: case 148: - case 147: - case 181: + case 184: if (node.typeParameters === list) { return 26; } @@ -59778,8 +61154,8 @@ var ts; return 18; } break; - case 175: - case 176: + case 178: + case 179: if (node.typeArguments === list) { return 26; } @@ -59787,7 +61163,7 @@ var ts; return 18; } break; - case 156: + case 157: if (node.typeArguments === list) { return 26; } @@ -59888,7 +61264,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 191) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -59990,7 +61366,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 256 || !parentAndChildShareLine); + (parent.kind === 260 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -60014,7 +61390,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 204 && parent.elseStatement === child) { + if (parent.kind === 207 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -60026,23 +61402,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 156: + case 157: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 172: + case 175: return node.parent.properties; - case 171: + case 174: return node.parent.elements; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: + case 149: case 148: - case 147: - case 152: - case 153: { + case 153: + case 154: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -60053,8 +61429,8 @@ var ts; } break; } - case 176: - case 175: { + case 179: + case 178: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -60082,8 +61458,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 175 || - node.parent.kind === 176) && + if (node.parent && (node.parent.kind === 178 || + node.parent.kind === 179) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -60101,10 +61477,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175: + case 178: + case 179: case 176: - case 173: - case 174: + case 177: node = node.expression; break; default: @@ -60158,48 +61534,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203: - case 222: - case 193: - case 223: + case 206: case 225: - case 224: - case 171: - case 200: - case 227: - case 172: - case 160: - case 162: + case 196: + case 226: case 228: - case 250: - case 249: - case 179: - case 173: + case 227: + case 174: + case 203: + case 230: case 175: + case 161: + case 163: + case 231: + case 253: + case 252: + case 182: case 176: - case 201: - case 219: - case 236: - case 212: - case 189: - case 169: - case 168: - case 244: - case 243: - case 248: - case 147: - case 152: - case 153: - case 143: - case 157: - case 158: - case 165: - case 177: - case 185: - case 238: - case 234: + case 178: + case 179: + case 204: + case 222: case 239: - case 235: + case 215: + case 192: + case 172: + case 171: + case 247: + case 246: + case 251: + case 148: + case 153: + case 154: + case 144: + case 158: + case 159: + case 166: + case 180: + case 188: + case 241: + case 237: + case 242: + case 238: return true; } return false; @@ -60207,27 +61583,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 205: - case 206: case 208: case 209: + case 211: + case 212: + case 210: case 207: - case 204: - case 221: - case 180: - case 148: - case 181: + case 224: + case 183: case 149: + case 184: case 150: case 151: - return childKind !== 200; - case 237: - return childKind !== 238; - case 231: - return childKind !== 232 || - (child.namedBindings && child.namedBindings.kind !== 234); - case 242: - return childKind !== 245; + case 152: + return childKind !== 203; + case 240: + return childKind !== 241; + case 234: + return childKind !== 235 || + (child.namedBindings && child.namedBindings.kind !== 237); + case 245: + return childKind !== 248; } return indentByDefault; } @@ -60308,7 +61684,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 175) { + if (superCall.expression && superCall.expression.kind == 178) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -60332,7 +61708,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 && ts.isSuperCall(n.expression)) { + if (n.kind === 206 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -60348,7 +61724,7 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 140 ? new NodeObject(kind, pos, end) : + var node = kind >= 141 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -60406,11 +61782,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286, nodes.pos, nodes.end, this); + var list = createNode(290, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -60425,11 +61801,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 140) { + if (this.kind >= 141) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285; + var useJSDocScanner_1 = this.kind >= 277 && this.kind <= 289; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -60483,7 +61859,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 140 ? child : child.getFirstToken(sourceFile); + return child.kind < 141 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -60491,7 +61867,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 140 ? child : child.getLastToken(sourceFile); + return child.kind < 141 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -60693,9 +62069,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 141) { + if (declaration.name.kind === 142) { var expr = declaration.name.expression; - if (expr.kind === 173) { + if (expr.kind === 176) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -60715,10 +62091,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221: - case 180: + case 224: + case 183: + case 149: case 148: - case 147: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -60735,30 +62111,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 222: - case 193: - case 223: - case 224: case 225: + case 196: case 226: - case 230: - case 239: - case 235: - case 230: - case 232: + case 227: + case 228: + case 229: case 233: - case 150: + case 242: + case 238: + case 233: + case 235: + case 236: case 151: - case 160: + case 152: + case 161: addDeclaration(node); ts.forEachChild(node, visit); break; - case 143: + case 144: if (!ts.hasModifier(node, 92)) { break; } - case 219: - case 170: { + case 222: + case 173: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -60767,24 +62143,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255: + case 259: + case 147: case 146: - case 145: addDeclaration(node); break; - case 237: + case 240: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231: + case 234: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 236) { addDeclaration(importClause.namedBindings); } else { @@ -60930,7 +62306,7 @@ var ts; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 5, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -61226,10 +62602,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 173: - case 140: + case 176: + case 141: case 98: - case 166: + case 167: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -61358,15 +62734,15 @@ var ts; return; } switch (node.kind) { - case 173: - case 140: + case 176: + case 141: case 9: case 85: case 100: case 94: case 96: case 98: - case 166: + case 167: case 70: break; default: @@ -61378,7 +62754,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 226 && + if (nodeForStartPos.parent.parent.kind === 229 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -61674,7 +63050,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 241 || + node.parent.kind === 244 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -61694,7 +63070,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 && + node.parent.kind === 177 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -61875,37 +63251,28 @@ var ts; this.host = host; this.project = project; this.cancellationToken = cancellationToken; - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.resolvedModuleNames = ts.createFileMap(); this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { this.trace = function (s) { return host.trace(s); }; } this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var globalCache = _this.project.getTypingOptions().enableAutoDiscovery + ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation + : undefined; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (primaryResult.resolvedModule) { - if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { - return primaryResult; + if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; + if (resolvedModule) { + return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; } } - var secondaryLookupFailedLookupLocations = []; - var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; - if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { - var traceEnabled = ts.isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); - } - var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; - var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); - if (resolvedName) { - return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); - } - } - if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { - primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); - } return primaryResult; }; + if (this.host.realpath) { + this.realpath = function (path) { return _this.host.realpath(path); }; + } } LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { this.filesWithChangedSetOfUnresolvedImports = []; @@ -61915,23 +63282,23 @@ var ts; this.filesWithChangedSetOfUnresolvedImports = undefined; return collected; }; - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, logChanges) { + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); var currentResolutionsInFile = cache.get(path); var newResolutions = ts.createMap(); var resolvedModules = []; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_52 = names_3[_i]; - var resolution = newResolutions[name_52]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name_48 = names_2[_i]; + var resolution = newResolutions[name_48]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_48]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + newResolutions[name_48] = resolution = loader(name_48, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -61958,7 +63325,7 @@ var ts; if (!oldResult || !newResult) { return false; } - return oldResult.resolvedFileName === newResult.resolvedFileName; + return getResultFileName(oldResult) === getResultFileName(newResult); } function moduleResolutionIsValid(resolution) { if (!resolution) { @@ -61966,10 +63333,7 @@ var ts; } var result = getResult(resolution); if (result) { - if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { - return false; - } - return true; + return getResultFileName(result) !== lastDeletedFileName; } return resolution.failedLookupLocations.length === 0; } @@ -61987,10 +63351,10 @@ var ts; return this.cancellationToken; }; LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, false); + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); }; LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, true); + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); }; LSHost.prototype.getDefaultLibFileName = function () { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); @@ -62163,7 +63527,6 @@ var ts; (function (ts) { var server; (function (server) { - var crypto = require("crypto"); function shouldEmitFile(scriptInfo) { return !scriptInfo.hasMixedContent; } @@ -62180,16 +63543,14 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 226 || statement.name.kind !== 9) { + if (statement.kind !== 229 || statement.name.kind !== 9) { return false; } } return true; }; BuilderFileInfo.prototype.computeHash = function (text) { - return crypto.createHash("md5") - .update(text) - .digest("base64"); + return this.project.projectService.host.createHash(text); }; BuilderFileInfo.prototype.getSourceFile = function () { return this.project.getSourceFile(this.scriptInfo.path); @@ -62465,12 +63826,12 @@ var ts; (function (ts) { var server; (function (server) { + var ProjectKind; (function (ProjectKind) { ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; ProjectKind[ProjectKind["External"] = 2] = "External"; - })(server.ProjectKind || (server.ProjectKind = {})); - var ProjectKind = server.ProjectKind; + })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); function remove(items, item) { var index = items.indexOf(item); if (index >= 0) { @@ -62563,8 +63924,8 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } - if (this.projectKind === ProjectKind.Inferred) { - this.compilerOptions.noEmitOverwritenFiles = true; + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; } if (languageServiceEnabled) { this.enableLanguageService(); @@ -62692,7 +64053,7 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; - Project.prototype.getFileNames = function () { + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { if (!this.program) { return []; } @@ -62706,8 +64067,15 @@ var ts; } return rootFiles; } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); + var result = []; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { + continue; + } + result.push(server.asNormalizedPath(f.fileName)); + } + return result; }; Project.prototype.getAllEmittableFiles = function () { if (!this.languageServiceEnabled) { @@ -62768,9 +64136,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_53 in file.resolvedModules) { - if (!file.resolvedModules[name_53] && !ts.isExternalModuleNameRelative(name_53)) { - var trimmed = name_53.trim(); + for (var name_49 in file.resolvedModules) { + if (!file.resolvedModules[name_49] && !ts.isExternalModuleNameRelative(name_49)) { + var trimmed = name_49.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -62991,9 +64359,8 @@ var ts; server.Project = Project; var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, false) || this; _this.directoriesWatchedForTsconfig = []; _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); InferredProject.NextId++; @@ -63323,6 +64690,7 @@ var ts; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; + ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); this.throttledOperations = new server.ThrottledOperations(host); @@ -63360,6 +64728,7 @@ var ts; }; ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var proj = _a[_i]; @@ -63910,7 +65279,7 @@ var ts; var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; var project = useExistingProject ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects); project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); project.updateGraph(); @@ -64043,13 +65412,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -64139,7 +65508,9 @@ var ts; var file = _a[_i]; var normalized = server.toNormalizedPath(file.fileName); if (ts.getBaseFileName(normalized) === "tsconfig.json") { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + if (this.host.fileExists(normalized)) { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } } else { rootFiles.push(file); @@ -65272,9 +66643,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_54 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_50 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_54, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_50, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -65677,6 +67048,7 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; + var CharRangeSection; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -65684,8 +67056,7 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(server.CharRangeSection || (server.CharRangeSection = {})); - var CharRangeSection = server.CharRangeSection; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); var BaseLineIndexWalker = (function () { function BaseLineIndexWalker() { this.goSubtree = true; @@ -66529,13 +67900,25 @@ var ts; var basePath; switch (process.platform) { case "win32": - basePath = process.env.LOCALAPPDATA || process.env.APPDATA || os.homedir(); + basePath = process.env.LOCALAPPDATA || + process.env.APPDATA || + (os.homedir && os.homedir()) || + process.env.USERPROFILE || + (process.env.HOMEDRIVE && process.env.HOMEPATH && ts.normalizeSlashes(process.env.HOMEDRIVE + process.env.HOMEPATH)) || + os.tmpdir(); break; case "linux": - basePath = os.homedir(); + basePath = (os.homedir && os.homedir()) || + process.env.HOME || + ((process.env.LOGNAME || process.env.USER) && "/home/" + (process.env.LOGNAME || process.env.USER)) || + os.tmpdir(); break; case "darwin": - basePath = ts.combinePaths(os.homedir(), "Library/Application Support/"); + var homeDir = (os.homedir && os.homedir()) || + process.env.HOME || + ((process.env.LOGNAME || process.env.USER) && "/Users/" + (process.env.LOGNAME || process.env.USER)) || + os.tmpdir(); + basePath = ts.combinePaths(homeDir, "Library/Application Support/"); break; } ts.Debug.assert(basePath !== undefined); @@ -66979,7 +68362,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index c96ca677639..024b85015c6 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1,5 +1,4 @@ /// -/// declare namespace ts.server.protocol { namespace CommandTypes { type Brace = "brace"; @@ -985,170 +984,176 @@ declare namespace ts { DeclareKeyword = 123, GetKeyword = 124, IsKeyword = 125, - ModuleKeyword = 126, - NamespaceKeyword = 127, - NeverKeyword = 128, - ReadonlyKeyword = 129, - RequireKeyword = 130, - NumberKeyword = 131, - SetKeyword = 132, - StringKeyword = 133, - SymbolKeyword = 134, - TypeKeyword = 135, - UndefinedKeyword = 136, - FromKeyword = 137, - GlobalKeyword = 138, - OfKeyword = 139, - QualifiedName = 140, - ComputedPropertyName = 141, - TypeParameter = 142, - Parameter = 143, - Decorator = 144, - PropertySignature = 145, - PropertyDeclaration = 146, - MethodSignature = 147, - MethodDeclaration = 148, - Constructor = 149, - GetAccessor = 150, - SetAccessor = 151, - CallSignature = 152, - ConstructSignature = 153, - IndexSignature = 154, - TypePredicate = 155, - TypeReference = 156, - FunctionType = 157, - ConstructorType = 158, - TypeQuery = 159, - TypeLiteral = 160, - ArrayType = 161, - TupleType = 162, - UnionType = 163, - IntersectionType = 164, - ParenthesizedType = 165, - ThisType = 166, - LiteralType = 167, - ObjectBindingPattern = 168, - ArrayBindingPattern = 169, - BindingElement = 170, - ArrayLiteralExpression = 171, - ObjectLiteralExpression = 172, - PropertyAccessExpression = 173, - ElementAccessExpression = 174, - CallExpression = 175, - NewExpression = 176, - TaggedTemplateExpression = 177, - TypeAssertionExpression = 178, - ParenthesizedExpression = 179, - FunctionExpression = 180, - ArrowFunction = 181, - DeleteExpression = 182, - TypeOfExpression = 183, - VoidExpression = 184, - AwaitExpression = 185, - PrefixUnaryExpression = 186, - PostfixUnaryExpression = 187, - BinaryExpression = 188, - ConditionalExpression = 189, - TemplateExpression = 190, - YieldExpression = 191, - SpreadElementExpression = 192, - ClassExpression = 193, - OmittedExpression = 194, - ExpressionWithTypeArguments = 195, - AsExpression = 196, - NonNullExpression = 197, - TemplateSpan = 198, - SemicolonClassElement = 199, - Block = 200, - VariableStatement = 201, - EmptyStatement = 202, - ExpressionStatement = 203, - IfStatement = 204, - DoStatement = 205, - WhileStatement = 206, - ForStatement = 207, - ForInStatement = 208, - ForOfStatement = 209, - ContinueStatement = 210, - BreakStatement = 211, - ReturnStatement = 212, - WithStatement = 213, - SwitchStatement = 214, - LabeledStatement = 215, - ThrowStatement = 216, - TryStatement = 217, - DebuggerStatement = 218, - VariableDeclaration = 219, - VariableDeclarationList = 220, - FunctionDeclaration = 221, - ClassDeclaration = 222, - InterfaceDeclaration = 223, - TypeAliasDeclaration = 224, - EnumDeclaration = 225, - ModuleDeclaration = 226, - ModuleBlock = 227, - CaseBlock = 228, - NamespaceExportDeclaration = 229, - ImportEqualsDeclaration = 230, - ImportDeclaration = 231, - ImportClause = 232, - NamespaceImport = 233, - NamedImports = 234, - ImportSpecifier = 235, - ExportAssignment = 236, - ExportDeclaration = 237, - NamedExports = 238, - ExportSpecifier = 239, - MissingDeclaration = 240, - ExternalModuleReference = 241, - JsxElement = 242, - JsxSelfClosingElement = 243, - JsxOpeningElement = 244, - JsxClosingElement = 245, - JsxAttribute = 246, - JsxSpreadAttribute = 247, - JsxExpression = 248, - CaseClause = 249, - DefaultClause = 250, - HeritageClause = 251, - CatchClause = 252, - PropertyAssignment = 253, - ShorthandPropertyAssignment = 254, - EnumMember = 255, - SourceFile = 256, - JSDocTypeExpression = 257, - JSDocAllType = 258, - JSDocUnknownType = 259, - JSDocArrayType = 260, - JSDocUnionType = 261, - JSDocTupleType = 262, - JSDocNullableType = 263, - JSDocNonNullableType = 264, - JSDocRecordType = 265, - JSDocRecordMember = 266, - JSDocTypeReference = 267, - JSDocOptionalType = 268, - JSDocFunctionType = 269, - JSDocVariadicType = 270, - JSDocConstructorType = 271, - JSDocThisType = 272, - JSDocComment = 273, - JSDocTag = 274, - JSDocParameterTag = 275, - JSDocReturnTag = 276, - JSDocTypeTag = 277, - JSDocTemplateTag = 278, - JSDocTypedefTag = 279, - JSDocPropertyTag = 280, - JSDocTypeLiteral = 281, - JSDocLiteralType = 282, - JSDocNullKeyword = 283, - JSDocUndefinedKeyword = 284, - JSDocNeverKeyword = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - Count = 289, + KeyOfKeyword = 126, + ModuleKeyword = 127, + NamespaceKeyword = 128, + NeverKeyword = 129, + ReadonlyKeyword = 130, + RequireKeyword = 131, + NumberKeyword = 132, + SetKeyword = 133, + StringKeyword = 134, + SymbolKeyword = 135, + TypeKeyword = 136, + UndefinedKeyword = 137, + FromKeyword = 138, + GlobalKeyword = 139, + OfKeyword = 140, + QualifiedName = 141, + ComputedPropertyName = 142, + TypeParameter = 143, + Parameter = 144, + Decorator = 145, + PropertySignature = 146, + PropertyDeclaration = 147, + MethodSignature = 148, + MethodDeclaration = 149, + Constructor = 150, + GetAccessor = 151, + SetAccessor = 152, + CallSignature = 153, + ConstructSignature = 154, + IndexSignature = 155, + TypePredicate = 156, + TypeReference = 157, + FunctionType = 158, + ConstructorType = 159, + TypeQuery = 160, + TypeLiteral = 161, + ArrayType = 162, + TupleType = 163, + UnionType = 164, + IntersectionType = 165, + ParenthesizedType = 166, + ThisType = 167, + TypeOperator = 168, + IndexedAccessType = 169, + LiteralType = 170, + ObjectBindingPattern = 171, + ArrayBindingPattern = 172, + BindingElement = 173, + ArrayLiteralExpression = 174, + ObjectLiteralExpression = 175, + PropertyAccessExpression = 176, + ElementAccessExpression = 177, + CallExpression = 178, + NewExpression = 179, + TaggedTemplateExpression = 180, + TypeAssertionExpression = 181, + ParenthesizedExpression = 182, + FunctionExpression = 183, + ArrowFunction = 184, + DeleteExpression = 185, + TypeOfExpression = 186, + VoidExpression = 187, + AwaitExpression = 188, + PrefixUnaryExpression = 189, + PostfixUnaryExpression = 190, + BinaryExpression = 191, + ConditionalExpression = 192, + TemplateExpression = 193, + YieldExpression = 194, + SpreadElement = 195, + ClassExpression = 196, + OmittedExpression = 197, + ExpressionWithTypeArguments = 198, + AsExpression = 199, + NonNullExpression = 200, + TemplateSpan = 201, + SemicolonClassElement = 202, + Block = 203, + VariableStatement = 204, + EmptyStatement = 205, + ExpressionStatement = 206, + IfStatement = 207, + DoStatement = 208, + WhileStatement = 209, + ForStatement = 210, + ForInStatement = 211, + ForOfStatement = 212, + ContinueStatement = 213, + BreakStatement = 214, + ReturnStatement = 215, + WithStatement = 216, + SwitchStatement = 217, + LabeledStatement = 218, + ThrowStatement = 219, + TryStatement = 220, + DebuggerStatement = 221, + VariableDeclaration = 222, + VariableDeclarationList = 223, + FunctionDeclaration = 224, + ClassDeclaration = 225, + InterfaceDeclaration = 226, + TypeAliasDeclaration = 227, + EnumDeclaration = 228, + ModuleDeclaration = 229, + ModuleBlock = 230, + CaseBlock = 231, + NamespaceExportDeclaration = 232, + ImportEqualsDeclaration = 233, + ImportDeclaration = 234, + ImportClause = 235, + NamespaceImport = 236, + NamedImports = 237, + ImportSpecifier = 238, + ExportAssignment = 239, + ExportDeclaration = 240, + NamedExports = 241, + ExportSpecifier = 242, + MissingDeclaration = 243, + ExternalModuleReference = 244, + JsxElement = 245, + JsxSelfClosingElement = 246, + JsxOpeningElement = 247, + JsxClosingElement = 248, + JsxAttribute = 249, + JsxSpreadAttribute = 250, + JsxExpression = 251, + CaseClause = 252, + DefaultClause = 253, + HeritageClause = 254, + CatchClause = 255, + PropertyAssignment = 256, + ShorthandPropertyAssignment = 257, + SpreadAssignment = 258, + EnumMember = 259, + SourceFile = 260, + JSDocTypeExpression = 261, + JSDocAllType = 262, + JSDocUnknownType = 263, + JSDocArrayType = 264, + JSDocUnionType = 265, + JSDocTupleType = 266, + JSDocNullableType = 267, + JSDocNonNullableType = 268, + JSDocRecordType = 269, + JSDocRecordMember = 270, + JSDocTypeReference = 271, + JSDocOptionalType = 272, + JSDocFunctionType = 273, + JSDocVariadicType = 274, + JSDocConstructorType = 275, + JSDocThisType = 276, + JSDocComment = 277, + JSDocTag = 278, + JSDocParameterTag = 279, + JSDocReturnTag = 280, + JSDocTypeTag = 281, + JSDocTemplateTag = 282, + JSDocTypedefTag = 283, + JSDocPropertyTag = 284, + JSDocTypeLiteral = 285, + JSDocLiteralType = 286, + JSDocNullKeyword = 287, + JSDocUndefinedKeyword = 288, + JSDocNeverKeyword = 289, + SyntaxList = 290, + NotEmittedStatement = 291, + PartiallyEmittedExpression = 292, + MergeDeclarationMarker = 293, + EndOfDeclarationMarker = 294, + Count = 295, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -1156,15 +1161,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 139, + LastKeyword = 140, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 155, - LastTypeNode = 167, + FirstTypeNode = 156, + LastTypeNode = 170, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -1173,11 +1178,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 261, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 289, } const enum NodeFlags { None = 0, @@ -1195,21 +1200,22 @@ declare namespace ts { HasDecorators = 2048, HasParamDecorators = 4096, HasAsyncFunctions = 8192, - HasJsxSpreadAttributes = 16384, - DisallowInContext = 32768, - YieldContext = 65536, - DecoratorContext = 131072, - AwaitContext = 262144, - ThisNodeHasError = 524288, - JavaScriptFile = 1048576, - ThisNodeOrAnySubNodesHasError = 2097152, - HasAggregatedChildData = 4194304, + HasSpreadAttribute = 16384, + HasRestAttribute = 32768, + DisallowInContext = 65536, + YieldContext = 131072, + DecoratorContext = 262144, + AwaitContext = 524288, + ThisNodeHasError = 1048576, + JavaScriptFile = 2097152, + ThisNodeOrAnySubNodesHasError = 4194304, + HasAggregatedChildData = 8388608, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 31744, - ReachabilityAndEmitFlags = 32128, - ContextFlags = 1540096, - TypeExcludesFlags = 327680, + EmitHelperFlags = 64512, + ReachabilityAndEmitFlags = 64896, + ContextFlags = 3080192, + TypeExcludesFlags = 655360, } const enum ModifierFlags { None = 0, @@ -1229,6 +1235,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } const enum JsxFlags { None = 0, @@ -1294,6 +1301,9 @@ declare namespace ts { interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } + interface GeneratedIdentifier extends Identifier { + autoGenerateKind: GeneratedIdentifierKind.Auto | GeneratedIdentifierKind.Loop | GeneratedIdentifierKind.Unique | GeneratedIdentifierKind.Node; + } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; @@ -1380,7 +1390,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -1394,6 +1404,10 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } + interface SpreadAssignment extends ObjectLiteralElement { + kind: SyntaxKind.SpreadAssignment; + expression: Expression; + } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; @@ -1516,6 +1530,16 @@ declare namespace ts { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } + interface TypeOperatorNode extends TypeNode { + kind: SyntaxKind.TypeOperator; + operator: SyntaxKind.KeyOfKeyword; + type: TypeNode; + } + interface IndexedAccessTypeNode extends TypeNode { + kind: SyntaxKind.IndexedAccessType; + objectType: TypeNode; + indexType: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; @@ -1553,9 +1577,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -1624,6 +1645,17 @@ declare namespace ts { operatorToken: BinaryOperatorToken; right: Expression; } + interface AssignmentExpression extends BinaryExpression { + left: LeftHandSideExpression; + operatorToken: Token; + } + interface ObjectDestructuringAssignment extends AssignmentExpression { + left: ObjectLiteralExpression; + } + interface ArrayDestructuringAssignment extends AssignmentExpression { + left: ArrayLiteralExpression; + } + type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; @@ -1692,8 +1724,8 @@ declare namespace ts { elements: NodeArray; multiLine?: boolean; } - interface SpreadElementExpression extends Expression { - kind: SyntaxKind.SpreadElementExpression; + interface SpreadElement extends Expression { + kind: SyntaxKind.SpreadElement; expression: Expression; } interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { @@ -1813,6 +1845,12 @@ declare namespace ts { interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } + interface EndOfDeclarationMarker extends Statement { + kind: SyntaxKind.EndOfDeclarationMarker; + } + interface MergeDeclarationMarker extends Statement { + kind: SyntaxKind.MergeDeclarationMarker; + } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } @@ -2265,14 +2303,16 @@ declare namespace ts { identifierCount: number; symbolCount: number; parseDiagnostics: Diagnostic[]; + additionalSyntacticDiagnostics?: Diagnostic[]; bindDiagnostics: Diagnostic[]; lineMap: number[]; classifiableNames?: Map; - resolvedModules: Map; + resolvedModules: Map; resolvedTypeReferenceDirectiveNames: Map; imports: LiteralExpression[]; moduleAugmentations: LiteralExpression[]; patternAmbientModules?: PatternAmbientModule[]; + ambientModuleNames: string[]; externalHelpersModuleName?: Identifier; } interface ScriptReferenceHost { @@ -2316,6 +2356,7 @@ declare namespace ts { getTypeCount(): number; getFileProcessingDiagnostics(): DiagnosticCollection; getResolvedTypeReferenceDirectives(): Map; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; structureIsReused?: boolean; } interface SourceMapSpan { @@ -2393,6 +2434,7 @@ declare namespace ts { getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; + tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(): Diagnostic[]; getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; @@ -2452,6 +2494,10 @@ declare namespace ts { NotAccessible = 1, CannotBeNamed = 2, } + const enum SyntheticSymbolKind { + UnionOrIntersection = 0, + Spread = 1, + } const enum TypePredicateKind { This = 0, Identifier = 1, @@ -2522,6 +2568,7 @@ declare namespace ts { getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; writeLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, writer: SymbolWriter): void; + getJsxFactoryEntity(): EntityName; } const enum SymbolFlags { None = 0, @@ -2619,6 +2666,8 @@ declare namespace ts { mapper?: TypeMapper; referenced?: boolean; containingType?: UnionOrIntersectionType; + leftSpread?: Symbol; + rightSpread?: Symbol; hasNonUniformType?: boolean; isPartial?: boolean; isDiscriminantProperty?: boolean; @@ -2695,10 +2744,12 @@ declare namespace ts { Object = 32768, Union = 65536, Intersection = 131072, - FreshLiteral = 262144, - ContainsWideningType = 524288, - ContainsObjectLiteral = 1048576, - ContainsAnyFunctionType = 2097152, + Index = 262144, + IndexedAccess = 524288, + FreshLiteral = 1048576, + ContainsWideningType = 2097152, + ContainsObjectLiteral = 4194304, + ContainsAnyFunctionType = 8388608, Nullable = 6144, Literal = 480, StringOrNumberLiteral = 96, @@ -2712,11 +2763,11 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 245760, - Narrowable = 246783, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, NotUnionOrUnit = 33281, - RequiresWidening = 1572864, - PropagatingFlags = 3670016, + RequiresWidening = 6291456, + PropagatingFlags = 14680064, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { @@ -2816,8 +2867,17 @@ declare namespace ts { target?: TypeParameter; mapper?: TypeMapper; resolvedApparentType: Type; + resolvedIndexType: IndexType; + resolvedIndexedAccessTypes: IndexedAccessType[]; isThisType?: boolean; } + interface IndexType extends Type { + type: TypeParameter; + } + interface IndexedAccessType extends Type { + objectType: Type; + indexType: TypeParameter; + } const enum SignatureKind { Call = 0, Construct = 1, @@ -2837,6 +2897,7 @@ declare namespace ts { erasedSignatureCache?: Signature; isolatedSignatureType?: ObjectType; typePredicate?: TypePredicate; + instantiations?: Map; } const enum IndexKind { String = 0, @@ -2850,7 +2911,6 @@ declare namespace ts { interface TypeMapper { (t: TypeParameter): Type; mappedTypes?: Type[]; - targetTypes?: Type[]; instantiations?: Type[]; context?: InferenceContext; } @@ -2941,7 +3001,7 @@ declare namespace ts { moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; - noEmitOverwritenFiles?: boolean; + noEmitForJsFiles?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; @@ -2962,6 +3022,7 @@ declare namespace ts { project?: string; pretty?: DiagnosticStyle; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -3031,7 +3092,8 @@ declare namespace ts { ES2015 = 2, ES2016 = 3, ES2017 = 4, - Latest = 4, + ESNext = 5, + Latest = 5, } const enum LanguageVariant { Standard = 0, @@ -3221,8 +3283,19 @@ declare namespace ts { resolvedFileName: string; isExternalLibraryImport?: boolean; } + interface ResolvedModuleFull extends ResolvedModule { + extension: Extension; + } + enum Extension { + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, + } interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; + resolvedModule: ResolvedModuleFull | undefined; failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { @@ -3255,49 +3328,54 @@ declare namespace ts { ContainsTypeScript = 2, Jsx = 4, ContainsJsx = 8, - ES2017 = 16, - ContainsES2017 = 32, - ES2016 = 64, - ContainsES2016 = 128, - ES2015 = 256, - ContainsES2015 = 512, - DestructuringAssignment = 1024, - Generator = 2048, - ContainsGenerator = 4096, - ContainsDecorators = 8192, - ContainsPropertyInitializer = 16384, - ContainsLexicalThis = 32768, - ContainsCapturedLexicalThis = 65536, - ContainsLexicalThisInComputedPropertyName = 131072, - ContainsDefaultValueAssignments = 262144, - ContainsParameterPropertyAssignments = 524288, - ContainsSpreadElementExpression = 1048576, - ContainsComputedPropertyName = 2097152, - ContainsBlockScopedBinding = 4194304, - ContainsBindingPattern = 8388608, - ContainsYield = 16777216, - ContainsHoistedDeclarationOrCompletion = 33554432, + ESNext = 16, + ContainsESNext = 32, + ES2017 = 64, + ContainsES2017 = 128, + ES2016 = 256, + ContainsES2016 = 512, + ES2015 = 1024, + ContainsES2015 = 2048, + Generator = 4096, + ContainsGenerator = 8192, + DestructuringAssignment = 16384, + ContainsDestructuringAssignment = 32768, + ContainsDecorators = 65536, + ContainsPropertyInitializer = 131072, + ContainsLexicalThis = 262144, + ContainsCapturedLexicalThis = 524288, + ContainsLexicalThisInComputedPropertyName = 1048576, + ContainsDefaultValueAssignments = 2097152, + ContainsParameterPropertyAssignments = 4194304, + ContainsSpreadExpression = 8388608, + ContainsComputedPropertyName = 16777216, + ContainsBlockScopedBinding = 33554432, + ContainsBindingPattern = 67108864, + ContainsYield = 134217728, + ContainsHoistedDeclarationOrCompletion = 268435456, HasComputedFlags = 536870912, AssertTypeScript = 3, AssertJsx = 12, - AssertES2017 = 48, - AssertES2016 = 192, - AssertES2015 = 768, - AssertGenerator = 6144, - NodeExcludes = 536874325, - ArrowFunctionExcludes = 592227669, - FunctionExcludes = 592293205, - ConstructorExcludes = 591760725, - MethodOrAccessorExcludes = 591760725, - ClassExcludes = 539749717, - ModuleExcludes = 574729557, + AssertESNext = 48, + AssertES2017 = 192, + AssertES2016 = 768, + AssertES2015 = 3072, + AssertGenerator = 12288, + AssertDestructuringAssignment = 49152, + NodeExcludes = 536892757, + ArrowFunctionExcludes = 979719509, + FunctionExcludes = 980243797, + ConstructorExcludes = 975983957, + MethodOrAccessorExcludes = 975983957, + ClassExcludes = 559895893, + ModuleExcludes = 839734613, TypeExcludes = -3, - ObjectLiteralExcludes = 539110741, - ArrayLiteralOrCallOrNewExcludes = 537922901, - VariableDeclarationListExcludes = 545262933, - ParameterExcludes = 545262933, - TypeScriptClassSyntaxMask = 548864, - ES2015FunctionSyntaxMask = 327680, + ObjectLiteralExcludes = 554784085, + ArrayLiteralOrCallOrNewExcludes = 545281365, + VariableDeclarationListExcludes = 604001621, + ParameterExcludes = 604001621, + TypeScriptClassSyntaxMask = 4390912, + ES2015FunctionSyntaxMask = 2621440, } interface EmitNode { flags?: EmitFlags; @@ -3335,6 +3413,8 @@ declare namespace ts { AsyncFunctionBody = 2097152, ReuseTempVariableScope = 4194304, CustomPrologue = 8388608, + NoHoisting = 16777216, + HasEndOfDeclarationMarker = 33554432, } const enum EmitContext { SourceFile = 0, @@ -3395,6 +3475,7 @@ declare namespace ts { GreaterThan = 1, } function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined; + function zipWith(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void; function every(array: T[], callback: (element: T, index: number) => boolean): boolean; function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined; function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U; @@ -3419,15 +3500,17 @@ declare namespace ts { function arrayIsEqualTo(array1: ReadonlyArray, array2: ReadonlyArray, equaler?: (a: T, b: T) => boolean): boolean; function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean; function compact(array: T[]): T[]; + function relativeComplement(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer?: (x: T, y: T) => Comparison, offsetA?: number, offsetB?: number): T[] | undefined; function sum(array: any[], prop: string): number; - function addRange(to: T[], from: T[]): void; + function append(to: T[] | undefined, value: T | undefined): T[] | undefined; + function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined; function rangeEquals(array1: T[], array2: T[], pos: number, end: number): boolean; function firstOrUndefined(array: T[]): T; + function lastOrUndefined(array: T[]): T; function singleOrUndefined(array: T[]): T; function singleOrMany(array: T[]): T | T[]; - function lastOrUndefined(array: T[]): T; function replaceElement(array: T[], index: number, value: T): T[]; - function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number; + function binarySearch(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number; function reduceLeft(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; function reduceLeft(array: T[], f: (memo: T, value: T, i: number) => T): T; function reduceRight(array: T[], f: (memo: U, value: T, i: number) => U, initial: U, start?: number, count?: number): U; @@ -3450,7 +3533,7 @@ declare namespace ts { function cloneMap(map: Map): Map; function clone(object: T): T; function extend(first: T1, second: T2): T1 & T2; - function multiMapAdd(map: Map, key: string, value: V): V[]; + function multiMapAdd(map: Map, key: string | number, value: V): V[]; function multiMapRemove(map: Map, key: string, value: V): void; function isArray(value: any): value is any[]; function noop(): void; @@ -3498,9 +3581,11 @@ declare namespace ts { function containsPath(parent: string, child: string, currentDirectory: string, ignoreCase?: boolean): boolean; function startsWith(str: string, prefix: string): boolean; function endsWith(str: string, suffix: string): boolean; + function hasExtension(fileName: string): boolean; function fileExtensionIs(path: string, extension: string): boolean; function fileExtensionIsAny(path: string, extensions: string[]): boolean; function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude"): string; + function isImplicitGlob(lastPathComponent: string): boolean; interface FileSystemEntries { files: string[]; directories: string[]; @@ -3535,7 +3620,6 @@ declare namespace ts { function removeFileExtension(path: string): string; function tryRemoveExtension(path: string, extension: string): string | undefined; function removeExtension(path: string, extension: string): string; - function isJsxOrTsxExtension(ext: string): boolean; function changeExtension(path: T, newExtension: string): T; interface ObjectAllocator { getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; @@ -3569,6 +3653,8 @@ declare namespace ts { function findBestPatternMatch(values: T[], getPattern: (value: T) => Pattern, candidate: string): T | undefined; function tryParsePattern(pattern: string): Pattern | undefined; function positionIsSynthesized(pos: number): boolean; + function extensionIsTypeScript(ext: Extension): boolean; + function extensionFromPath(path: string): Extension; } declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; @@ -3586,7 +3672,7 @@ declare namespace ts { readFile(path: string, encoding?: string): string; getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; + watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; @@ -3863,7 +3949,7 @@ declare namespace ts { key: string; message: string; }; - Type_0_is_not_a_valid_async_function_return_type: { + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: number; category: DiagnosticCategory; key: string; @@ -5225,7 +5311,7 @@ declare namespace ts { key: string; message: string; }; - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: number; category: DiagnosticCategory; key: string; @@ -5267,7 +5353,7 @@ declare namespace ts { key: string; message: string; }; - Invalid_left_hand_side_of_assignment_expression: { + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: number; category: DiagnosticCategory; key: string; @@ -5507,7 +5593,7 @@ declare namespace ts { key: string; message: string; }; - Invalid_left_hand_side_in_for_in_statement: { + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: number; category: DiagnosticCategory; key: string; @@ -5735,18 +5821,6 @@ declare namespace ts { key: string; message: string; }; - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; Cannot_redeclare_block_scoped_variable_0: { code: number; category: DiagnosticCategory; @@ -5813,7 +5887,7 @@ declare namespace ts { key: string; message: string; }; - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: number; category: DiagnosticCategory; key: string; @@ -5945,19 +6019,7 @@ declare namespace ts { key: string; message: string; }; - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { - code: number; - category: DiagnosticCategory; - key: string; - message: string; - }; - Invalid_left_hand_side_in_for_of_statement: { + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: number; category: DiagnosticCategory; key: string; @@ -6239,6 +6301,48 @@ declare namespace ts { key: string; message: string; }; + Type_0_is_not_constrained_to_keyof_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_has_no_matching_index_signature_for_type_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Type_0_cannot_be_used_as_an_index_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_assign_to_0_because_it_is_not_a_variable: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Index_signature_in_type_0_only_permits_reading: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; JSX_element_attributes_type_0_may_not_be_a_union_type: { code: number; category: DiagnosticCategory; @@ -6377,6 +6481,12 @@ declare namespace ts { key: string; message: string; }; + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: number; category: DiagnosticCategory; @@ -6563,6 +6673,24 @@ declare namespace ts { key: string; message: string; }; + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Spread_types_may_only_be_created_from_object_types: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Rest_types_may_only_be_created_from_object_types: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Import_declaration_0_is_using_private_name_1: { code: number; category: DiagnosticCategory; @@ -7157,6 +7285,12 @@ declare namespace ts { key: string; message: string; }; + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Concatenate_and_emit_output_to_single_file: { code: number; category: DiagnosticCategory; @@ -7655,7 +7789,7 @@ declare namespace ts { key: string; message: string; }; - package_json_does_not_have_types_field: { + package_json_does_not_have_a_types_or_main_field: { code: number; category: DiagnosticCategory; key: string; @@ -7877,7 +8011,7 @@ declare namespace ts { key: string; message: string; }; - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: number; category: DiagnosticCategory; key: string; @@ -7907,6 +8041,36 @@ declare namespace ts { key: string; message: string; }; + Module_0_was_resolved_to_1_but_jsx_is_not_set: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Variable_0_implicitly_has_an_1_type: { code: number; category: DiagnosticCategory; @@ -7955,7 +8119,13 @@ declare namespace ts { key: string; message: string; }; - Index_signature_of_object_type_implicitly_has_an_any_type: { + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: number; category: DiagnosticCategory; key: string; @@ -8297,6 +8467,12 @@ declare namespace ts { key: string; message: string; }; + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; }; } declare namespace ts { @@ -8516,26 +8692,19 @@ declare namespace ts.server { declare namespace ts { function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean; - function createResolvedModule(resolvedFileName: string, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations; - interface ModuleResolutionState { - host: ModuleResolutionHost; - compilerOptions: CompilerOptions; - traceEnabled: boolean; - skipTsx: boolean; - } function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean; getCurrentDirectory?: () => string; }): string[] | undefined; - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; function directoryProbablyExists(directoryName: string, host: { directoryExists?: (directoryName: string) => boolean; }): boolean; - function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState, checkOneLevel: boolean): string; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + function loadModuleFromGlobalCache(moduleName: string, projectName: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { const externalHelpersModuleNameText = "tslib"; @@ -8562,10 +8731,10 @@ declare namespace ts { function releaseStringWriter(writer: StringSymbolWriter): void; function getFullWidth(node: Node): number; function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean; - function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule; - function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void; + function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull; + function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void; function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void; - function moduleResolutionIsEqualTo(oldResolution: ResolvedModule, newResolution: ResolvedModule): boolean; + function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean; function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean; function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean; function containsParseError(node: Node): boolean; @@ -8600,7 +8769,10 @@ declare namespace ts { function isBlockScope(node: Node, parentNode: Node): boolean; function getEnclosingBlockScopeContainer(node: Node): Node; function declarationNameToString(name: DeclarationName): string; + function getTextOfPropertyName(name: PropertyName): string; + function entityNameToString(name: EntityNameOrEntityNameExpression): string; function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; + function createDiagnosticForNodeInSourceFile(sourceFile: SourceFile, node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic; function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic; function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan; function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan; @@ -8672,6 +8844,12 @@ declare namespace ts { function hasDeclaredRestParameter(s: SignatureDeclaration): boolean; function isRestParameter(node: ParameterDeclaration): boolean; function isDeclaredRestParam(node: ParameterDeclaration): boolean; + const enum AssignmentKind { + None = 0, + Definite = 1, + Compound = 2, + } + function getAssignmentTargetKind(node: Node): AssignmentKind; function isAssignmentTarget(node: Node): boolean; function isNodeDescendantOf(node: Node, ancestor: Node): boolean; function isInAmbientContext(node: Node): boolean; @@ -8704,6 +8882,7 @@ declare namespace ts { function nodeStartsNewLexicalEnvironment(node: Node): boolean; function nodeIsSynthesized(node: TextRange): boolean; function getOriginalNode(node: Node): Node; + function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; function isParseTreeNode(node: Node): boolean; function getParseTreeNode(node: Node): Node; function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; @@ -8716,7 +8895,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElementExpression | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.Count; + function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.LiteralType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxAttribute | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocArrayType | SyntaxKind.JSDocUnionType | SyntaxKind.JSDocTupleType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocRecordType | SyntaxKind.JSDocRecordMember | SyntaxKind.JSDocTypeReference | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocConstructorType | SyntaxKind.JSDocThisType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocLiteralType | SyntaxKind.JSDocNullKeyword | SyntaxKind.JSDocUndefinedKeyword | SyntaxKind.JSDocNeverKeyword | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): 0 | 1 | -1 | 2 | 4 | 3 | 16 | 10 | 5 | 6 | 11 | 8 | 19 | 18 | 17 | 15 | 14 | 13 | 12 | 9 | 7; function createDiagnosticCollection(): DiagnosticCollection; function escapeString(s: string): string; @@ -8787,7 +8966,8 @@ declare namespace ts { function isLogicalOperator(token: SyntaxKind): boolean; function isAssignmentOperator(token: SyntaxKind): boolean; function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined; - function isDestructuringAssignment(node: Node): node is BinaryExpression; + function isAssignmentExpression(node: Node): node is AssignmentExpression; + function isDestructuringAssignment(node: Node): node is DestructuringAssignment; function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean; function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean; function isEntityNameExpression(node: Expression): node is EntityNameExpression; @@ -8817,12 +8997,16 @@ declare namespace ts { function rangeEndIsOnSameLineAsRangeStart(range1: TextRange, range2: TextRange, sourceFile: SourceFile): boolean; function positionsAreOnSameLine(pos1: number, pos2: number, sourceFile: SourceFile): boolean; function getStartPositionOfRange(range: TextRange, sourceFile: SourceFile): number; - function collectExternalModuleInfo(sourceFile: SourceFile): { - externalImports: (ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration)[]; + interface ExternalModuleInfo { + externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; exportSpecifiers: Map; - exportEquals: ExportAssignment; + exportedBindings: Map; + exportedNames: Identifier[]; + exportEquals: ExportAssignment | undefined; hasExportStarsToExportValues: boolean; - }; + } + function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver): ExternalModuleInfo; + function isDeclarationNameOfEnumOrNamespace(node: Identifier): boolean; function getInitializedVariables(node: VariableDeclarationList): VariableDeclaration[]; function isMergedWithClass(node: Node): boolean; function isFirstDeclarationOfKind(node: Node, kind: SyntaxKind): boolean; @@ -8835,7 +9019,7 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isIdentifier(node: Node): node is Identifier; - function isGeneratedIdentifier(node: Node): boolean; + function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier; function isModifier(node: Node): node is Modifier; function isQualifiedName(node: Node): node is QualifiedName; function isComputedPropertyName(node: Node): node is ComputedPropertyName; @@ -8853,13 +9037,15 @@ declare namespace ts { function isBindingPattern(node: Node): node is BindingPattern; function isBindingElement(node: Node): node is BindingElement; function isArrayBindingElement(node: Node): node is ArrayBindingElement; + function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; + function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; function isElementAccessExpression(node: Node): node is ElementAccessExpression; function isBinaryExpression(node: Node): node is BinaryExpression; function isConditionalExpression(node: Node): node is ConditionalExpression; function isCallExpression(node: Node): node is CallExpression; function isTemplateLiteral(node: Node): node is TemplateLiteral; - function isSpreadElementExpression(node: Node): node is SpreadElementExpression; + function isSpreadExpression(node: Node): node is SpreadElement; function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments; function isLeftHandSideExpression(node: Node): node is LeftHandSideExpression; function isUnaryExpression(node: Node): node is UnaryExpression; @@ -8955,9 +9141,8 @@ declare namespace ts { function createNull(): PrimaryExpression; function createComputedPropertyName(expression: Expression, location?: TextRange): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(name: string | Identifier | BindingPattern, initializer?: Expression, location?: TextRange): ParameterDeclaration; - function createParameterDeclaration(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; - function updateParameterDeclaration(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression, location?: TextRange, flags?: NodeFlags): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression, location?: TextRange): PropertyDeclaration; function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags): MethodDeclaration; @@ -9014,8 +9199,8 @@ declare namespace ts { function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression, location?: TextRange): YieldExpression; function updateYield(node: YieldExpression, expression: Expression): YieldExpression; - function createSpread(expression: Expression, location?: TextRange): SpreadElementExpression; - function updateSpread(node: SpreadElementExpression, expression: Expression): SpreadElementExpression; + function createSpread(expression: Expression, location?: TextRange): SpreadElement; + function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; function createClassExpression(modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[], location?: TextRange): ClassExpression; function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; function createOmittedExpression(location?: TextRange): OmittedExpression; @@ -9111,9 +9296,13 @@ declare namespace ts { function createPropertyAssignment(name: string | PropertyName, initializer: Expression, location?: TextRange): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression, location?: TextRange): ShorthandPropertyAssignment; + function createSpreadAssignment(expression: Expression, location?: TextRange): SpreadAssignment; function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function updateSourceFileNode(node: SourceFile, statements: Statement[]): SourceFile; function createNotEmittedStatement(original: Node): NotEmittedStatement; + function createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; + function createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; function createPartiallyEmittedExpression(expression: Expression, original?: Node, location?: TextRange): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; function createComma(left: Expression, right: Expression): Expression; @@ -9129,13 +9318,15 @@ declare namespace ts { function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createMemberAccessForPropertyName(target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression; - function createRestParameter(name: string | Identifier): ParameterDeclaration; function createFunctionCall(func: Expression, thisArg: Expression, argumentsList: Expression[], location?: TextRange): CallExpression; function createFunctionApply(func: Expression, thisArg: Expression, argumentsExpression: Expression, location?: TextRange): CallExpression; function createArraySlice(array: Expression, start?: number | Expression): CallExpression; function createArrayConcat(array: Expression, values: Expression[]): CallExpression; function createMathPow(left: Expression, right: Expression, location?: TextRange): CallExpression; - function createReactCreateElement(reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; + function createExpressionForJsxElement(jsxFactoryEntity: EntityName, reactNamespace: string, tagName: Expression, props: Expression, children: Expression[], parentElement: JsxOpeningLikeElement, location: TextRange): LeftHandSideExpression; + function createExportDefault(expression: Expression): ExportAssignment; + function createExternalModuleExport(exportName: Identifier): ExportDeclaration; + function createLetStatement(name: Identifier, initializer: Expression, location?: TextRange): VariableStatement; function createLetDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; function createConstDeclarationList(declarations: VariableDeclaration[], location?: TextRange): VariableDeclarationList; function createHelperName(externalHelpersModuleName: Identifier | undefined, name: string): Identifier | PropertyAccessExpression; @@ -9157,6 +9348,13 @@ declare namespace ts { function createExpressionFromEntityName(node: EntityName | Expression): Expression; function createExpressionForPropertyName(memberName: PropertyName): Expression; function createExpressionForObjectLiteralElementLike(node: ObjectLiteralExpression, property: ObjectLiteralElementLike, receiver: Expression): Expression; + function getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; + function isLocalName(node: Identifier): boolean; + function getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; + function isExportName(node: Identifier): boolean; + function getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; + function getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; + function getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number; function ensureUseStrict(node: SourceFile): SourceFile; function parenthesizeBinaryOperand(binaryOperator: SyntaxKind, operand: Expression, isLeftSideOfBinary: boolean, leftOperand?: Expression): Expression; @@ -9201,11 +9399,18 @@ declare namespace ts { function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier; function getExternalModuleNameLiteral(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions): StringLiteral; function tryGetModuleNameFromFile(file: SourceFile, host: EmitHost, options: CompilerOptions): StringLiteral; + function transformFunctionBody(node: FunctionLikeDeclaration, visitor: (node: Node) => VisitResult, currentSourceFile: SourceFile, context: TransformationContext, enableSubstitutionsForCapturedThis: () => void, convertObjectRest?: boolean): Block; + function addCaptureThisForNodeIfNeeded(statements: Statement[], node: Node, enableSubstitutionsForCapturedThis: () => void): void; + function captureThisForNode(statements: Statement[], node: Node, initializer: Expression | undefined, enableSubstitutionsForCapturedThis?: () => void, originalStatement?: Statement): void; + function addDefaultValueAssignmentsIfNeeded(statements: Statement[], node: FunctionLikeDeclaration, visitor: (node: Node) => VisitResult, convertObjectRest: boolean): void; + function addRestParameterIfNeeded(statements: Statement[], node: FunctionLikeDeclaration, inConstructorWithSynthesizedSuper: boolean): void; + function convertForOf(node: ForOfStatement, convertedLoopBodyStatements: Statement[], visitor: (node: Node) => VisitResult, enableSubstitutionsForBlockScopedBindings: () => void, context: TransformationContext, convertObjectRest?: boolean): ForStatement | ForOfStatement; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function parseIsolatedJSDocComment(content: string, start?: number, length?: number): { @@ -9252,10 +9457,10 @@ declare namespace ts { } } declare namespace ts { - function flattenDestructuringAssignment(context: TransformationContext, node: BinaryExpression, needsValue: boolean, recordTempVariable: (node: Identifier) => void, visitor?: (node: Node) => VisitResult): Expression; - function flattenParameterDestructuring(node: ParameterDeclaration, value: Expression, visitor?: (node: Node) => VisitResult): VariableDeclaration[]; - function flattenVariableDestructuring(node: VariableDeclaration, value?: Expression, visitor?: (node: Node) => VisitResult, recordTempVariable?: (node: Identifier) => void): VariableDeclaration[]; - function flattenVariableDestructuringToExpression(node: VariableDeclaration, recordTempVariable: (name: Identifier) => void, nameSubstitution?: (name: Identifier) => Expression, visitor?: (node: Node) => VisitResult): Expression; + function flattenDestructuringAssignment(context: TransformationContext, node: BinaryExpression, needsValue: boolean, recordTempVariable: (node: Identifier) => void, visitor?: (node: Node) => VisitResult, transformRest?: boolean): Expression; + function flattenParameterDestructuring(node: ParameterDeclaration, value: Expression, visitor?: (node: Node) => VisitResult, transformRest?: boolean): VariableDeclaration[]; + function flattenVariableDestructuring(node: VariableDeclaration, value?: Expression, visitor?: (node: Node) => VisitResult, recordTempVariable?: (node: Identifier) => void, transformRest?: boolean): VariableDeclaration[]; + function flattenVariableDestructuringToExpression(node: VariableDeclaration, recordTempVariable: (name: Identifier) => void, createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression, visitor?: (node: Node) => VisitResult): Expression; } declare namespace ts { function transformTypeScript(context: TransformationContext): (node: SourceFile) => SourceFile; @@ -9263,6 +9468,9 @@ declare namespace ts { declare namespace ts { function transformJsx(context: TransformationContext): (node: SourceFile) => SourceFile; } +declare namespace ts { + function transformESNext(context: TransformationContext): (node: SourceFile) => SourceFile; +} declare namespace ts { function transformES2017(context: TransformationContext): (node: SourceFile) => SourceFile; } @@ -9342,7 +9550,7 @@ declare namespace ts { function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; } declare namespace ts { - const version = "2.1.2"; + const version = "2.1.3"; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; @@ -9356,6 +9564,7 @@ declare namespace ts { function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; + function getResolutionDiagnostic(options: CompilerOptions, {extension}: ResolvedModuleFull): DiagnosticMessage | undefined; } declare namespace ts { interface Node { @@ -10609,16 +10818,17 @@ declare namespace ts.server { private filesWithChangedSetOfUnresolvedImports; private readonly resolveModuleName; readonly trace: (s: string) => void; + readonly realpath?: (path: string) => string; constructor(host: ServerHost, project: Project, cancellationToken: HostCancellationToken); startRecordingFilesWithChangedResolutions(): void; finishRecordingFilesWithChangedResolutions(): Path[]; - private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, logChanges); + private resolveNamesWithLocalCache(names, containingFile, cache, loader, getResult, getResultFileName, logChanges); getProjectVersion(): string; getCompilationSettings(): CompilerOptions; useCaseSensitiveFileNames(): boolean; getCancellationToken(): HostCancellationToken; resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; - resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[]; + resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModuleFull[]; getDefaultLibFileName(): string; getScriptSnapshot(filename: string): ts.IScriptSnapshot; getScriptFileNames(): string[]; @@ -10740,7 +10950,7 @@ declare namespace ts.server { getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; getFileEmitOutput(info: ScriptInfo, emitOnlyDtsFiles: boolean): EmitOutput; - getFileNames(): NormalizedPath[]; + getFileNames(excludeFilesFromExternalLibraries?: boolean): NormalizedPath[]; getAllEmittableFiles(): string[]; containsScriptInfo(info: ScriptInfo): boolean; containsFile(filename: NormalizedPath, requireOpen?: boolean): boolean; @@ -10763,11 +10973,10 @@ declare namespace ts.server { private removeRootFileIfNecessary(info); } class InferredProject extends Project { - compileOnSaveEnabled: boolean; private static NextId; private readonly inferredProjectName; directoriesWatchedForTsconfig: string[]; - constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + constructor(projectService: ProjectService, documentRegistry: ts.DocumentRegistry, languageServiceEnabled: boolean, compilerOptions: CompilerOptions); getProjectName(): string; getProjectRootPath(): string; close(): void; @@ -11348,7 +11557,7 @@ declare namespace ts { private files; private loggingEnabled; private tracingEnabled; - resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; + resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModuleFull[]; resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[]; directoryExists: (directoryName: string) => boolean; constructor(shimHost: LanguageServiceShimHost); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index e41a11039ad..f2e1dd09ae9 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -26,12 +26,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -44,19 +45,19 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; + })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var ModuleResolutionKind; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; + })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -64,8 +65,16 @@ var ts; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; + })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -204,6 +213,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; function every(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -463,20 +479,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -552,6 +573,26 @@ var ts; return result || array; } ts.compact = compact; + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1: break inner; + case 0: continue outer; + case 1: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -561,15 +602,23 @@ var ts; return result; } ts.sum = sum; + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -588,6 +637,12 @@ var ts; : undefined; } ts.firstOrUndefined = firstOrUndefined; + function lastOrUndefined(array) { + return array && array.length > 0 + ? array[array.length - 1] + : undefined; + } + ts.lastOrUndefined = lastOrUndefined; function singleOrUndefined(array) { return array && array.length === 1 ? array[0] @@ -600,23 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; - } - ts.lastOrUndefined = lastOrUndefined; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; return result; } ts.replaceElement = replaceElement; - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -1374,6 +1423,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -1401,68 +1454,83 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + if (component.charCodeAt(0) === 42) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -1529,25 +1597,30 @@ var ts; for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) { var include = includes_1[_i]; var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); } - basePaths.push(includeBasePath); + }; + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { return (scriptKind || getScriptKindFromFileName(fileName)) || 3; } @@ -1647,10 +1720,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -1796,6 +1865,30 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2090,6 +2183,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -2099,7 +2193,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -2107,7 +2201,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -2122,7 +2216,7 @@ var ts; watchDirectory: function (directoryName, callback, recursive) { var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -2319,7 +2413,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -2546,14 +2640,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -2593,7 +2687,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -2631,8 +2725,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2644,7 +2736,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2666,9 +2758,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -2715,6 +2805,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2738,6 +2835,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -2769,6 +2867,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2868,6 +2969,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -2951,7 +3053,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -2988,11 +3090,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3001,7 +3108,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -3058,6 +3166,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); var ts; @@ -3090,7 +3199,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3100,34 +3209,35 @@ var ts; "instanceof": 92, "interface": 108, "is": 125, + "keyof": 126, "let": 109, - "module": 126, - "namespace": 127, - "never": 128, + "module": 127, + "namespace": 128, + "never": 129, "new": 93, "null": 94, - "number": 131, + "number": 132, "package": 110, "private": 111, "protected": 112, "public": 113, - "readonly": 129, - "require": 130, - "global": 138, + "readonly": 130, + "require": 131, + "global": 139, "return": 95, - "set": 132, + "set": 133, "static": 114, - "string": 133, + "string": 134, "super": 96, "switch": 97, - "symbol": 134, + "symbol": 135, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 135, + "type": 136, "typeof": 102, - "undefined": 136, + "undefined": 137, "var": 103, "void": 104, "while": 105, @@ -3135,7 +3245,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -4522,9 +4632,9 @@ var ts; pos++; return token = 22; } - if (isIdentifierStart(ch, 4)) { + if (isIdentifierStart(ch, 5)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } return token = 70; @@ -4683,6 +4793,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -4870,6 +4985,7 @@ var ts; "es2015": 2, "es2016": 3, "es2017": 4, + "esnext": 5, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -5026,7 +5142,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -5513,9 +5630,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -5646,14 +5761,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_6); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -5674,6 +5788,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); @@ -5742,7 +5869,7 @@ var ts; mergeTypings(typingOptions.include); exclude = typingOptions.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { + if (projectRootPath) { possibleSearchDirs.push(projectRootPath); } searchDirs = ts.deduplicate(possibleSearchDirs); @@ -5765,9 +5892,9 @@ var ts; } } } - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + for (var name_6 in packageNameToTypingLocation) { + if (name_6 in inferredTypings && !inferredTypings[name_6]) { + inferredTypings[name_6] = packageNameToTypingLocation[name_6]; } } for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { @@ -5897,13 +6024,13 @@ var ts; (function (ts) { var server; (function (server) { + var LogLevel; (function (LogLevel) { LogLevel[LogLevel["terse"] = 0] = "terse"; LogLevel[LogLevel["normal"] = 1] = "normal"; LogLevel[LogLevel["requestTime"] = 2] = "requestTime"; LogLevel[LogLevel["verbose"] = 3] = "verbose"; - })(server.LogLevel || (server.LogLevel = {})); - var LogLevel = server.LogLevel; + })(LogLevel = server.LogLevel || (server.LogLevel = {})); server.emptyArray = []; var Msg; (function (Msg) { @@ -5925,7 +6052,7 @@ var ts; function createInstallTypingsRequest(project, typingOptions, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), - fileNames: project.getFileNames(), + fileNames: project.getFileNames(true), compilerOptions: project.getCompilerOptions(), typingOptions: typingOptions, unresolvedImports: unresolvedImports, @@ -6147,24 +6274,50 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2: + case 0: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -6173,18 +6326,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -6195,7 +6336,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -6234,7 +6374,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -6261,18 +6400,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -6284,15 +6422,12 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -6308,9 +6443,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -6323,8 +6456,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -6379,15 +6512,15 @@ var ts; return result; } ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -6421,7 +6554,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -6438,7 +6571,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -6449,7 +6582,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -6476,9 +6609,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -6488,53 +6621,63 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0) || tryResolve(1); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -6544,19 +6687,28 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { var directory = ts.getDirectoryPath(candidate); if (directory) { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { @@ -6580,18 +6732,21 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -6601,85 +6756,76 @@ var ts; } failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(0, moduleName, directory, failedLookupLocations, state, false, true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); + var resolved = tryResolve(0) || tryResolve(1); + return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -6690,6 +6836,18 @@ var ts; containingDirectory = parentPath; } } + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0, moduleName, globalCache, failedLookupLocations, state, true) || + loadModuleFromNodeModules(1, moduleName, globalCache, failedLookupLocations, state, true); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); var ts; (function (ts) { @@ -6764,7 +6922,9 @@ var ts; } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -6790,21 +6950,21 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 2097152) !== 0; + return (node.flags & 4194304) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 4194304)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288) !== 0) || + if (!(node.flags & 8388608)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152; + node.flags |= 4194304; } - node.flags |= 4194304; + node.flags |= 8388608; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 256) { + while (node && node.kind !== 260) { node = node.parent; } return node; @@ -6812,11 +6972,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: return true; } return false; @@ -6881,18 +7041,18 @@ var ts; if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { return getTokenPosOfNode(node.jsDocComments[0]); } - if (node.kind === 286 && node._children.length > 0) { + if (node.kind === 290 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 257 && node.kind <= 282; + return node.kind >= 261 && node.kind <= 286; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 && node.kind <= 285; + return node.kind >= 277 && node.kind <= 289; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6986,11 +7146,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 219 && node.parent.kind === 252; + return node.kind === 222 && node.parent.kind === 255; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 && + return node && node.kind === 229 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -6999,11 +7159,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node.kind === 226 && (!node.body); + return node.kind === 229 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 || - node.kind === 226 || + return node.kind === 260 || + node.kind === 229 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7016,9 +7176,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256: + case 260: return ts.isExternalModule(node.parent); - case 227: + case 230: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7026,22 +7186,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { - case 256: - case 228: - case 252: - case 226: - case 207: - case 208: - case 209: - case 149: - case 148: + case 260: + case 231: + case 255: + case 229: + case 210: + case 211: + case 212: case 150: + case 149: case 151: - case 221: - case 180: - case 181: + case 152: + case 224: + case 183: + case 184: return true; - case 200: + case 203: return parentNode && !isFunctionLike(parentNode); } return false; @@ -7061,12 +7221,42 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70: + return name.text; + case 9: + case 8: + return name.text; + case 142: + if (isStringOrNumericLiteral(name.expression.kind)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70: + return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); + case 141: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 176: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { var span = getErrorSpanForNode(sourceFile, node); return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } - ts.createDiagnosticForNode = createDiagnosticForNode; + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -7089,7 +7279,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200) { + if (node.body && node.body.kind === 203) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7101,29 +7291,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256: + case 260: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 219: - case 170: case 222: - case 193: - case 223: - case 226: + case 173: case 225: - case 255: - case 221: - case 180: - case 148: - case 150: - case 151: + case 196: + case 226: + case 229: + case 228: + case 259: case 224: + case 183: + case 149: + case 151: + case 152: + case 227: errorNode = node.name; break; - case 181: + case 184: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7144,7 +7334,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 && isConst(node); + return node.kind === 228 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7157,11 +7347,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 && n.expression.kind === 96; + return n.kind === 178 && n.expression.kind === 96; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 && node.expression.kind === 9; + return node.kind === 206 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -7177,10 +7367,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 || - node.kind === 142 || - node.kind === 180 || - node.kind === 181) ? + var commentRanges = (node.kind === 144 || + node.kind === 143 || + node.kind === 183 || + node.kind === 184) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -7195,69 +7385,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (155 <= node.kind && node.kind <= 167) { + if (156 <= node.kind && node.kind <= 170) { return true; } switch (node.kind) { case 118: - case 131: - case 133: - case 121: + case 132: case 134: - case 136: - case 128: + case 121: + case 135: + case 137: + case 129: return true; case 104: - return node.parent.kind !== 184; - case 195: + return node.parent.kind !== 187; + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); case 70: - if (node.parent.kind === 140 && node.parent.right === node) { + if (node.parent.kind === 141 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 173 && node.parent.name === node) { + else if (node.parent.kind === 176 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 140 || node.kind === 173, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 140: - case 173: + ts.Debug.assert(node.kind === 70 || node.kind === 141 || node.kind === 176, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141: + case 176: case 98: var parent_2 = node.parent; - if (parent_2.kind === 159) { + if (parent_2.kind === 160) { return false; } - if (155 <= parent_2.kind && parent_2.kind <= 167) { + if (156 <= parent_2.kind && parent_2.kind <= 170) { return true; } switch (parent_2.kind) { - case 195: + case 198: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); - case 142: - return node === parent_2.constraint; - case 146: - case 145: case 143: - case 219: + return node === parent_2.constraint; + case 147: + case 146: + case 144: + case 222: return node === parent_2.type; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: + case 150: case 149: case 148: - case 147: - case 150: case 151: - return node === parent_2.type; case 152: + return node === parent_2.type; case 153: case 154: + case 155: + return node === parent_2.type; + case 181: return node === parent_2.type; case 178: - return node === parent_2.type; - case 175: - case 176: + case 179: return parent_2.typeArguments && ts.indexOf(parent_2.typeArguments, node) >= 0; - case 177: + case 180: return false; } } @@ -7268,23 +7458,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212: + case 215: return visitor(node); - case 228: - case 200: - case 204: - case 205: - case 206: + case 231: + case 203: case 207: case 208: case 209: - case 213: - case 214: - case 249: - case 250: - case 215: + case 210: + case 211: + case 212: + case 216: case 217: case 252: + case 253: + case 218: + case 220: + case 255: return ts.forEachChild(node, traverse); } } @@ -7294,24 +7484,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191: + case 194: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225: - case 223: + case 228: case 226: - case 224: - case 222: - case 193: + case 229: + case 227: + case 225: + case 196: return; default: if (isFunctionLike(node)) { - var name_8 = node.name; - if (name_8 && name_8.kind === 141) { - traverse(name_8.expression); + var name_7 = node.name; + if (name_7 && name_7.kind === 142) { + traverse(name_7.expression); return; } } @@ -7325,14 +7515,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170: - case 255: - case 143: - case 253: + case 173: + case 259: + case 144: + case 256: + case 147: case 146: - case 145: - case 254: - case 219: + case 257: + case 222: return true; } } @@ -7340,11 +7530,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 150 || node.kind === 151); + return node && (node.kind === 151 || node.kind === 152); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 222 || node.kind === 193); + return node && (node.kind === 225 || node.kind === 196); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7353,19 +7543,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 149: - case 180: - case 221: - case 181: - case 148: - case 147: case 150: + case 183: + case 224: + case 184: + case 149: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return true; } return false; @@ -7373,13 +7563,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 180: + case 152: + case 224: + case 183: return true; } return false; @@ -7387,30 +7577,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207: + case 210: + case 211: + case 212: case 208: case 209: - case 205: - case 206: return true; - case 215: + case 218: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 200 && isFunctionLike(node.parent); + return node && node.kind === 203 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 148 && node.parent.kind === 172; + return node && node.kind === 149 && node.parent.kind === 175; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 && - (node.parent.kind === 172 || - node.parent.kind === 193); + return node.kind === 149 && + (node.parent.kind === 175 || + node.parent.kind === 196); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7446,39 +7636,39 @@ var ts; return undefined; } switch (node.kind) { - case 141: + case 142: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 181: + case 184: if (!includeArrowFunctions) { continue; } - case 221: - case 180: - case 226: - case 146: - case 145: - case 148: + case 224: + case 183: + case 229: case 147: + case 146: case 149: + case 148: case 150: case 151: case 152: case 153: case 154: - case 225: - case 256: + case 155: + case 228: + case 260: return node; } } @@ -7491,25 +7681,25 @@ var ts; return node; } switch (node.kind) { - case 141: + case 142: node = node.parent; break; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: if (!stopOnFunctions) { continue; } - case 146: - case 145: - case 148: case 147: + case 146: case 149: + case 148: case 150: case 151: + case 152: return node; - case 144: - if (node.parent.kind === 143 && isClassElement(node.parent.parent)) { + case 145: + if (node.parent.kind === 144 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -7521,14 +7711,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 || func.kind === 181) { + if (func.kind === 183 || func.kind === 184) { var prev = func; var parent_3 = func.parent; - while (parent_3.kind === 179) { + while (parent_3.kind === 182) { prev = parent_3; parent_3 = parent_3.parent; } - if (parent_3.kind === 175 && parent_3.expression === prev) { + if (parent_3.kind === 178 && parent_3.expression === prev) { return parent_3; } } @@ -7536,32 +7726,32 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 || kind === 174) + return (kind === 176 || kind === 177) && node.expression.kind === 96; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 156: - return node.typeName; - case 195: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 70: - case 140: - return node; - } + switch (node.kind) { + case 157: + case 271: + return node.typeName; + case 198: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70: + case 141: + return node; } return undefined; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 175: - case 176: - case 177: - case 144: + case 178: + case 179: + case 180: + case 145: return true; default: return false; @@ -7569,7 +7759,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177) { + if (node.kind === 180) { return node.tag; } return node.expression; @@ -7577,21 +7767,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222: + case 225: return true; - case 146: - return node.parent.kind === 222; - case 150: + case 147: + return node.parent.kind === 225; case 151: - case 148: + case 152: + case 149: return node.body !== undefined - && node.parent.kind === 222; - case 143: + && node.parent.kind === 225; + case 144: return node.parent.body !== undefined - && (node.parent.kind === 149 - || node.parent.kind === 148 - || node.parent.kind === 151) - && node.parent.parent.kind === 222; + && (node.parent.kind === 150 + || node.parent.kind === 149 + || node.parent.kind === 152) + && node.parent.parent.kind === 225; } return false; } @@ -7607,19 +7797,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222: + case 225: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148: - case 151: + case 149: + case 152: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 244 || - parent.kind === 243 || - parent.kind === 245) { + if (parent.kind === 247 || + parent.kind === 246 || + parent.kind === 248) { return parent.tagName === node; } return false; @@ -7633,43 +7823,43 @@ var ts; case 100: case 85: case 11: - case 171: - case 172: - case 173: case 174: case 175: case 176: case 177: - case 196: case 178: - case 197: case 179: case 180: - case 193: + case 199: case 181: - case 184: + case 200: case 182: case 183: - case 186: + case 196: + case 184: case 187: - case 188: - case 189: - case 192: - case 190: - case 12: - case 194: - case 242: - case 243: - case 191: case 185: + case 186: + case 189: + case 190: + case 191: + case 192: + case 195: + case 193: + case 12: + case 197: + case 245: + case 246: + case 194: + case 188: return true; - case 140: - while (node.parent.kind === 140) { + case 141: + while (node.parent.kind === 141) { node = node.parent; } - return node.parent.kind === 159 || isJSXTagName(node); + return node.parent.kind === 160 || isJSXTagName(node); case 70: - if (node.parent.kind === 159 || isJSXTagName(node)) { + if (node.parent.kind === 160 || isJSXTagName(node)) { return true; } case 8: @@ -7677,47 +7867,47 @@ var ts; case 98: var parent_4 = node.parent; switch (parent_4.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 255: - case 253: - case 170: + case 259: + case 256: + case 173: return parent_4.initializer === node; - case 203: - case 204: - case 205: case 206: - case 212: - case 213: - case 214: - case 249: - case 216: - case 214: - return parent_4.expression === node; case 207: - var forStatement = parent_4; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220) || - forStatement.condition === node || - forStatement.incrementor === node; case 208: case 209: + case 215: + case 216: + case 217: + case 252: + case 219: + case 217: + return parent_4.expression === node; + case 210: + var forStatement = parent_4; + return (forStatement.initializer === node && forStatement.initializer.kind !== 223) || + forStatement.condition === node || + forStatement.incrementor === node; + case 211: + case 212: var forInStatement = parent_4; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 223) || forInStatement.expression === node; - case 178: - case 196: + case 181: + case 199: return node === parent_4.expression; - case 198: + case 201: return node === parent_4.expression; - case 141: + case 142: return node === parent_4.expression; - case 144: - case 248: - case 247: + case 145: + case 251: + case 250: return true; - case 195: + case 198: return parent_4.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_4); default: if (isPartOfExpression(parent_4)) { @@ -7735,7 +7925,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind === 241; + return node.kind === 233 && node.moduleReference.kind === 244; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7744,7 +7934,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 && node.moduleReference.kind !== 241; + return node.kind === 233 && node.moduleReference.kind !== 244; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7752,11 +7942,11 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576); + return node && !!(node.flags & 2097152); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 175 && + var isRequire = expression.kind === 178 && expression.expression.kind === 70 && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7768,9 +7958,9 @@ var ts; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219) { + if (s.valueDeclaration && s.valueDeclaration.kind === 222) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180; + return declaration.initializer && declaration.initializer.kind === 183; } return false; } @@ -7779,11 +7969,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 188) { + if (expression.kind !== 191) { return 0; } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 173) { + if (expr.operatorToken.kind !== 57 || expr.left.kind !== 176) { return 0; } var lhs = expr.left; @@ -7799,7 +7989,7 @@ var ts; else if (lhs.expression.kind === 98) { return 4; } - else if (lhs.expression.kind === 173) { + else if (lhs.expression.kind === 176) { var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; @@ -7815,35 +8005,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231) { + if (node.kind === 234) { return node.moduleSpecifier; } - if (node.kind === 230) { + if (node.kind === 233) { var reference = node.moduleReference; - if (reference.kind === 241) { + if (reference.kind === 244) { return reference.expression; } } - if (node.kind === 237) { + if (node.kind === 240) { return node.moduleSpecifier; } - if (node.kind === 226 && node.name.kind === 9) { + if (node.kind === 229 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 236) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 + return node.kind === 234 && node.importClause && !!node.importClause.name; } @@ -7851,13 +8041,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143: + case 144: + case 149: case 148: + case 257: + case 256: case 147: - case 254: - case 253: case 146: - case 145: return node.questionToken !== undefined; } } @@ -7865,9 +8055,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 && + return node.kind === 273 && node.parameters.length > 0 && - node.parameters[0].type.kind === 271; + node.parameters[0].type.kind === 275; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7918,32 +8108,32 @@ var ts; if (checkParentVariableStatement) { var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 201; + node.parent.parent.parent.kind === 204; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201; + node.parent.parent.kind === 204; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 226 && - node.parent && node.parent.kind === 226) { + if (node.kind === 229 && + node.parent && node.parent.kind === 229) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } var parent_5 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_5 && parent_5.parent && - parent_5.kind === 188 && + parent_5.kind === 191 && parent_5.operatorToken.kind === 57 && - parent_5.parent.kind === 203; + parent_5.parent.kind === 206; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_5.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 253; + var isPropertyAssignmentExpression = parent_5 && parent_5.kind === 256; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_5, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 143) { + if (node.kind === 144) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7968,14 +8158,14 @@ var ts; var tags = getJSDocTags(func, checkParentVariableStatement); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { - var name_9 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 && tag.parameterName.text === name_9; }); + var name_8 = param.name.text; + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 && tag.parameterName.text === name_8; }); if (paramTags) { return paramTags; } @@ -7985,15 +8175,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277, false); + return getJSDocTag(node, 281, false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276, true); + return getJSDocTag(node, 280, true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278, false); + return getJSDocTag(node, 282, false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -8005,7 +8195,7 @@ var ts; } for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { var tag = jsDocTags_2[_i]; - if (tag.kind === 275) { + if (tag.kind === 279) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -8025,13 +8215,13 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 1048576)) { - if (node.type && node.type.kind === 270) { + if (node && (node.flags & 2097152)) { + if (node.type && node.type.kind === 274) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270; + return paramTag.typeExpression.type.kind === 274; } } return isDeclaredRestParam(node); @@ -8041,27 +8231,44 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; - function isAssignmentTarget(node) { - while (node.parent.kind === 179) { - node = node.parent; - } + function getAssignmentTargetKind(node) { + var parent = node.parent; while (true) { - var parent_6 = node.parent; - if (parent_6.kind === 171 || parent_6.kind === 192) { - node = parent_6; - continue; + switch (parent.kind) { + case 191: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 ? 1 : 2 : + 0; + case 189: + case 190: + var unaryOperator = parent.operator; + return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; + case 211: + case 212: + return parent.initializer === node ? 1 : 0; + case 182: + case 174: + case 195: + node = parent; + break; + case 257: + if (parent.name !== node) { + return 0; + } + case 256: + node = parent.parent; + break; + default: + return 0; } - if (parent_6.kind === 253 || parent_6.kind === 254) { - node = parent_6.parent; - continue; - } - return parent_6.kind === 188 && - isAssignmentOperator(parent_6.operatorToken.kind) && - parent_6.left === node || - (parent_6.kind === 208 || parent_6.kind === 209) && - parent_6.initializer === node; + parent = node.parent; } } + ts.getAssignmentTargetKind = getAssignmentTargetKind; + function isAssignmentTarget(node) { + return getAssignmentTargetKind(node) !== 0; + } ts.isAssignmentTarget = isAssignmentTarget; function isNodeDescendantOf(node, ancestor) { while (node) { @@ -8074,7 +8281,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 256 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 260 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8087,7 +8294,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 || parent.kind === 239) { + if (parent.kind === 238 || parent.kind === 242) { if (parent.propertyName) { return true; } @@ -8100,48 +8307,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 141 && + node.parent.kind === 142 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 146: - case 145: - case 148: case 147: - case 150: + case 146: + case 149: + case 148: case 151: - case 255: - case 253: - case 173: + case 152: + case 259: + case 256: + case 176: return parent.name === node; - case 140: + case 141: if (parent.right === node) { - while (parent.kind === 140) { + while (parent.kind === 141) { parent = parent.parent; } - return parent.kind === 159; + return parent.kind === 160; } return false; - case 170: - case 235: + case 173: + case 238: return parent.propertyName === node; - case 239: + case 242: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 230 || - node.kind === 229 || - node.kind === 232 && !!node.name || - node.kind === 233 || - node.kind === 235 || - node.kind === 239 || - node.kind === 236 && exportAssignmentIsAlias(node); + return node.kind === 233 || + node.kind === 232 || + node.kind === 235 && !!node.name || + node.kind === 236 || + node.kind === 238 || + node.kind === 242 || + node.kind === 239 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8227,7 +8434,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 139; + return 71 <= token && token <= 140; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -8247,7 +8454,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 && + return name.kind === 142 && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8257,10 +8464,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 143) { + if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 144) { return name.text; } - if (name.kind === 141) { + if (name.kind === 142) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8296,7 +8503,7 @@ var ts; case 113: case 111: case 112: - case 129: + case 130: case 114: return true; } @@ -8305,11 +8512,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 143; + return root.kind === 144; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 170) { + while (node.kind === 173) { node = node.parent.parent; } return node; @@ -8317,15 +8524,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 149 - || kind === 180 - || kind === 221 - || kind === 181 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 183 + || kind === 224 + || kind === 184 + || kind === 149 || kind === 151 - || kind === 226 - || kind === 256; + || kind === 152 + || kind === 229 + || kind === 260; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8333,13 +8540,13 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { + function getOriginalNode(node, nodeTest) { if (node) { while (node.original !== undefined) { node = node.original; } } - return node; + return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; function isParseTreeNode(node) { @@ -8376,23 +8583,23 @@ var ts; ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176: + case 179: return hasArguments ? 0 : 1; - case 186: - case 183: - case 184: - case 182: - case 185: case 189: - case 191: - return 1; + case 186: + case 187: + case 185: case 188: + case 192: + case 194: + return 1; + case 191: switch (operator) { case 39: case 57: @@ -8416,15 +8623,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188) { + if (expression.kind === 191) { return expression.operatorToken.kind; } - else if (expression.kind === 186 || expression.kind === 187) { + else if (expression.kind === 189 || expression.kind === 190) { return expression.operator; } else { @@ -8442,36 +8649,36 @@ var ts; case 85: case 8: case 9: - case 171: - case 172: - case 180: - case 181: - case 193: - case 242: - case 243: - case 11: - case 12: - case 190: - case 179: - case 194: - return 19; - case 177: - case 173: case 174: - return 18; - case 176: - return hasArguments ? 18 : 17; case 175: - return 17; - case 187: - return 16; - case 186: case 183: case 184: + case 196: + case 245: + case 246: + case 11: + case 12: + case 193: case 182: + case 197: + return 19; + case 180: + case 176: + case 177: + return 18; + case 179: + return hasArguments ? 18 : 17; + case 178: + return 17; + case 190: + return 16; + case 189: + case 186: + case 187: case 185: - return 15; case 188: + return 15; + case 191: switch (operatorKind) { case 50: case 51: @@ -8529,11 +8736,11 @@ var ts; default: return -1; } - case 189: - return 4; - case 191: - return 2; case 192: + return 4; + case 194: + return 2; + case 195: return 1; default: return -1; @@ -8779,13 +8986,16 @@ var ts; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); + var sourceFiles = getAllEmittableSourceFiles(); return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; return ts.filter(sourceFiles, isNonDeclarationFile); } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } } ts.getSourceFilesToEmit = getSourceFilesToEmit; function isNonDeclarationFile(sourceFile) { @@ -8843,7 +9053,7 @@ var ts; onBundledEmit(host); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) { @@ -8873,7 +9083,7 @@ var ts; action(emitFileNames, [sourceFile], false, emitOnlyDtsFiles); } function onBundledEmit(host) { - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || !!ts.getEmitModuleKind(options)); }); @@ -8913,7 +9123,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 149 && nodeIsPresent(member.body)) { + if (member.kind === 150 && nodeIsPresent(member.body)) { return member; } }); @@ -8954,10 +9164,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 150) { + if (accessor.kind === 151) { getAccessor = accessor; } - else if (accessor.kind === 151) { + else if (accessor.kind === 152) { setAccessor = accessor; } else { @@ -8966,7 +9176,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 150 || member.kind === 151) + if ((member.kind === 151 || member.kind === 152) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8977,10 +9187,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 150 && !getAccessor) { + if (member.kind === 151 && !getAccessor) { getAccessor = member; } - if (member.kind === 151 && !setAccessor) { + if (member.kind === 152 && !setAccessor) { setAccessor = member; } } @@ -9182,7 +9392,7 @@ var ts; case 75: return 2048; case 78: return 512; case 119: return 256; - case 129: return 64; + case 130: return 64; } return 0; } @@ -9198,19 +9408,25 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 && + if (node.kind === 198 && node.parent.token === 84 && isClassLike(node.parent.parent)) { return node.parent.parent; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node) { + return isBinaryExpression(node) + && isAssignmentOperator(node.operatorToken.kind) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { if (node.operatorToken.kind === 57) { var kind = node.left.kind; - return kind === 172 - || kind === 171; + return kind === 175 + || kind === 174; } } return false; @@ -9237,20 +9453,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 || - node.kind === 173 && isEntityNameExpression(node.expression); + node.kind === 176 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 140 && node.parent.right === node) || - (node.parent.kind === 173 && node.parent.name === node); + return (node.parent.kind === 141 && node.parent.right === node) || + (node.parent.kind === 176 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172) { + if (kind === 175) { return expression.properties.length === 0; } - if (kind === 171) { + if (kind === 174) { return expression.elements.length === 0; } return false; @@ -9384,39 +9600,39 @@ var ts; || kind === 94) { return true; } - else if (kind === 173) { + else if (kind === 176) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174) { + else if (kind === 177) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 - || kind === 187) { + else if (kind === 189 + || kind === 190) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188) { + else if (kind === 191) { return node.operatorToken.kind !== 39 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189) { + else if (kind === 192) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 184 - || kind === 183 - || kind === 182) { + else if (kind === 187 + || kind === 186 + || kind === 185) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171) { + else if (kind === 174) { return node.elements.length === 0; } - else if (kind === 172) { + else if (kind === 175) { return node.properties.length === 0; } - else if (kind === 175) { + else if (kind === 178) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9438,9 +9654,9 @@ var ts; if (syntaxKindCache[kind]) { return syntaxKindCache[kind]; } - for (var name_10 in syntaxKindEnum) { - if (syntaxKindEnum[name_10] === kind) { - return syntaxKindCache[kind] = kind.toString() + " (" + name_10 + ")"; + for (var name_9 in syntaxKindEnum) { + if (syntaxKindEnum[name_9] === kind) { + return syntaxKindCache[kind] = kind.toString() + " (" + name_9 + ")"; } } } @@ -9522,23 +9738,26 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile, resolver) { var externalImports = []; var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 231: + case 234: externalImports.push(node); break; - case 230: - if (node.moduleReference.kind === 241) { + case 233: + if (node.moduleReference.kind === 244) { externalImports.push(node); } break; - case 237: + case 240: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -9551,21 +9770,102 @@ var ts; else { for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_11 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_11] || (exportSpecifiers[name_11] = [])).push(specifier); + if (!uniqueExports[specifier.name.text]) { + var name_10 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_10) + || resolver.getReferencedValueDeclaration(name_10); + if (decl) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = specifier.name; + } } } break; - case 236: + case 239: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; + case 204: + if (hasModifier(node, 1)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + collectExportedVariableInfo(decl, uniqueExports); + } + } + break; + case 224: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_11 = node.name; + if (!uniqueExports[name_11.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_11); + uniqueExports[name_11.text] = name_11; + } + } + } + break; + case 225: + if (hasModifier(node, 1)) { + if (hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_12 = node.name; + if (!uniqueExports[name_12.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_12); + uniqueExports[name_12.text] = name_12; + } + } + } + break; } } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + var exportedNames; + for (var key in uniqueExports) { + exportedNames = ts.append(exportedNames, uniqueExports[key]); + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; } ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports) { + if (isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!isOmittedExpression(element)) { + collectExportedVariableInfo(element, uniqueExports); + } + } + } + else if (!isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = decl.name; + } + } + } + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 228: + case 229: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9577,7 +9877,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 && declaration !== node) { + if (declaration.kind === 225 && declaration !== node) { return true; } } @@ -9637,16 +9937,16 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 140; + return node.kind === 141; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 141; + return node.kind === 142; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 140 + return kind === 141 || kind === 70; } ts.isEntityName = isEntityName; @@ -9655,7 +9955,7 @@ var ts; return kind === 70 || kind === 9 || kind === 8 - || kind === 141; + || kind === 142; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9667,57 +9967,58 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 - || kind === 168 - || kind === 169; + || kind === 171 + || kind === 172; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 142; + return node.kind === 143; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 143; + return node.kind === 144; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 144; + return node.kind === 145; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 148; + return node.kind === 149; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 149 - || kind === 146 - || kind === 148 - || kind === 150 + return kind === 150 + || kind === 147 + || kind === 149 || kind === 151 - || kind === 154 - || kind === 199; + || kind === 152 + || kind === 155 + || kind === 202; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 - || kind === 254 - || kind === 148 - || kind === 150 + return kind === 256 + || kind === 257 + || kind === 258 + || kind === 149 || kind === 151 - || kind === 240; + || kind === 152 + || kind === 243; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 155 && kind <= 167) + return (kind >= 156 && kind <= 170) || kind === 118 - || kind === 131 + || kind === 132 || kind === 121 - || kind === 133 || kind === 134 + || kind === 135 || kind === 104 - || kind === 128 - || kind === 195; + || kind === 129 + || kind === 198; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -9726,94 +10027,102 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 - || kind === 168; + return kind === 172 + || kind === 171; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170; + return node.kind === 173; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 - || kind === 194; + return kind === 173 + || kind === 197; } ts.isArrayBindingElement = isArrayBindingElement; + function isArrayLiteralExpression(node) { + return node.kind === 174; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 175; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173; + return node.kind === 176; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174; + return node.kind === 177; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188; + return node.kind === 191; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189; + return node.kind === 192; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175; + return node.kind === 178; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 + return kind === 193 || kind === 12; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192; - } - ts.isSpreadElementExpression = isSpreadElementExpression; - function isExpressionWithTypeArguments(node) { + function isSpreadExpression(node) { return node.kind === 195; } + ts.isSpreadExpression = isSpreadExpression; + function isExpressionWithTypeArguments(node) { + return node.kind === 198; + } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 - || kind === 174 - || kind === 176 - || kind === 175 - || kind === 242 - || kind === 243 + return kind === 176 || kind === 177 - || kind === 171 || kind === 179 - || kind === 172 - || kind === 193 + || kind === 178 + || kind === 245 + || kind === 246 || kind === 180 + || kind === 174 + || kind === 182 + || kind === 175 + || kind === 196 + || kind === 183 || kind === 70 || kind === 11 || kind === 8 || kind === 9 || kind === 12 - || kind === 190 + || kind === 193 || kind === 85 || kind === 94 || kind === 98 || kind === 100 || kind === 96 - || kind === 197; + || kind === 200; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 - || kind === 187 - || kind === 182 - || kind === 183 - || kind === 184 + return kind === 189 + || kind === 190 || kind === 185 - || kind === 178 + || kind === 186 + || kind === 187 + || kind === 188 + || kind === 181 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9821,13 +10130,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 - || kind === 191 - || kind === 181 - || kind === 188 - || kind === 192 - || kind === 196 + return kind === 192 || kind === 194 + || kind === 184 + || kind === 191 + || kind === 195 + || kind === 199 + || kind === 197 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9836,16 +10145,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 - || kind === 196; + return kind === 181 + || kind === 199; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288; + return node.kind === 292; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287; + return node.kind === 291; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9854,15 +10163,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194; + return node.kind === 197; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 198; + return node.kind === 201; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 200; + return node.kind === 203; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9880,119 +10189,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219; + return node.kind === 222; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220; + return node.kind === 223; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228; + return node.kind === 231; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 - || kind === 226; + return kind === 230 + || kind === 229; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230; + return node.kind === 233; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232; + return node.kind === 235; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 - || kind === 233; + return kind === 237 + || kind === 236; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235; + return node.kind === 238; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238; + return node.kind === 241; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239; + return node.kind === 242; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 || node.kind === 225; + return node.kind === 229 || node.kind === 228; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 - || kind === 170 - || kind === 222 - || kind === 193 - || kind === 149 + return kind === 184 + || kind === 173 || kind === 225 - || kind === 255 - || kind === 239 - || kind === 221 - || kind === 180 + || kind === 196 || kind === 150 - || kind === 232 - || kind === 230 - || kind === 235 - || kind === 223 - || kind === 148 - || kind === 147 - || kind === 226 - || kind === 229 - || kind === 233 - || kind === 143 - || kind === 253 - || kind === 146 - || kind === 145 - || kind === 151 - || kind === 254 + || kind === 228 + || kind === 259 + || kind === 242 || kind === 224 - || kind === 142 - || kind === 219 - || kind === 279; + || kind === 183 + || kind === 151 + || kind === 235 + || kind === 233 + || kind === 238 + || kind === 226 + || kind === 149 + || kind === 148 + || kind === 229 + || kind === 232 + || kind === 236 + || kind === 144 + || kind === 256 + || kind === 147 + || kind === 146 + || kind === 152 + || kind === 257 + || kind === 227 + || kind === 143 + || kind === 222 + || kind === 283; } function isDeclarationStatementKind(kind) { - return kind === 221 - || kind === 240 - || kind === 222 - || kind === 223 - || kind === 224 + return kind === 224 + || kind === 243 || kind === 225 || kind === 226 - || kind === 231 - || kind === 230 - || kind === 237 - || kind === 236 - || kind === 229; + || kind === 227 + || kind === 228 + || kind === 229 + || kind === 234 + || kind === 233 + || kind === 240 + || kind === 239 + || kind === 232; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 - || kind === 210 - || kind === 218 - || kind === 205 - || kind === 203 - || kind === 202 - || kind === 208 - || kind === 209 - || kind === 207 - || kind === 204 - || kind === 215 - || kind === 212 - || kind === 214 - || kind === 216 - || kind === 217 - || kind === 201 - || kind === 206 + return kind === 214 || kind === 213 - || kind === 287; + || kind === 221 + || kind === 208 + || kind === 206 + || kind === 205 + || kind === 211 + || kind === 212 + || kind === 210 + || kind === 207 + || kind === 218 + || kind === 215 + || kind === 217 + || kind === 219 + || kind === 220 + || kind === 204 + || kind === 209 + || kind === 216 + || kind === 291 + || kind === 294 + || kind === 293; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10010,87 +10321,87 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200; + || kind === 203; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 241 - || kind === 140 + return kind === 244 + || kind === 141 || kind === 70; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 244; + return node.kind === 247; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245; + return node.kind === 248; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 || kind === 70 - || kind === 173; + || kind === 176; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 - || kind === 248 - || kind === 243 + return kind === 245 + || kind === 251 + || kind === 246 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 - || kind === 247; + return kind === 249 + || kind === 250; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247; + return node.kind === 250; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246; + return node.kind === 249; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 248; + || kind === 251; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 - || kind === 250; + return kind === 252 + || kind === 253; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251; + return node.kind === 254; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252; + return node.kind === 255; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 253; + return node.kind === 256; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254; + return node.kind === 257; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 256; + return node.kind === 260; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10101,6 +10412,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5: case 4: return "lib.es2017.d.ts"; case 3: @@ -10228,9 +10540,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 142) { + if (d && d.kind === 143) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 226) { return current; } } @@ -10238,11 +10550,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 149 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 150 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 || ts.isBindingPattern(node))) { + while (node && (node.kind === 173 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10250,14 +10562,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= ts.getModifierFlags(node); } return flags; @@ -10266,14 +10578,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219) { + if (node.kind === 222) { node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 223) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201) { + if (node && node.kind === 204) { flags |= node.flags; } return flags; @@ -10285,7 +10597,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 + var ConstructorForKind = kind === 260 ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10455,7 +10767,7 @@ var ts; } ts.createNull = createNull; function createComputedPropertyName(expression, location) { - var node = createNode(141, location); + var node = createNode(142, location); node.expression = expression; return node; } @@ -10467,12 +10779,8 @@ var ts; return node; } ts.updateComputedPropertyName = updateComputedPropertyName; - function createParameter(name, initializer, location) { - return createParameterDeclaration(undefined, undefined, undefined, name, undefined, undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(143, location, flags); + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(144, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10482,16 +10790,16 @@ var ts; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + ts.createParameter = createParameter; + function updateParameter(node, decorators, modifiers, name, type, initializer) { if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); + return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; + ts.updateParameter = updateParameter; function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(146, location); + var node = createNode(147, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10509,7 +10817,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(148, location, flags); + var node = createNode(149, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10529,7 +10837,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(149, location, flags); + var node = createNode(150, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10547,7 +10855,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(150, location, flags); + var node = createNode(151, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10566,7 +10874,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(151, location, flags); + var node = createNode(152, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10584,7 +10892,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements, location) { - var node = createNode(168, location); + var node = createNode(171, location); node.elements = createNodeArray(elements); return node; } @@ -10597,7 +10905,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169, location); + var node = createNode(172, location); node.elements = createNodeArray(elements); return node; } @@ -10610,7 +10918,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170, location); + var node = createNode(173, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10626,7 +10934,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171, location); + var node = createNode(174, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10642,7 +10950,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172, location); + var node = createNode(175, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10658,7 +10966,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173, location, flags); + var node = createNode(176, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10675,7 +10983,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174, location); + var node = createNode(177, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10689,7 +10997,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175, location, flags); + var node = createNode(178, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10706,7 +11014,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176, location, flags); + var node = createNode(179, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10721,7 +11029,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177, location); + var node = createNode(180, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10735,7 +11043,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179, location); + var node = createNode(182, location); node.expression = expression; return node; } @@ -10748,7 +11056,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(180, location, flags); + var node = createNode(183, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10767,7 +11075,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(181, location, flags); + var node = createNode(184, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10785,7 +11093,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182, location); + var node = createNode(185, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10798,7 +11106,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183, location); + var node = createNode(186, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10811,7 +11119,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184, location); + var node = createNode(187, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10824,7 +11132,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185, location); + var node = createNode(188, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10837,7 +11145,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186, location); + var node = createNode(189, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10851,7 +11159,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187, location); + var node = createNode(190, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10867,7 +11175,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(188, location); + var node = createNode(191, location); node.left = parenthesizeBinaryOperand(operatorKind, left, true, undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, false, node.left); @@ -10882,7 +11190,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189, location); + var node = createNode(192, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10899,7 +11207,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190, location); + var node = createNode(193, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10913,7 +11221,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191, location); + var node = createNode(194, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10927,7 +11235,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192, location); + var node = createNode(195, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10940,7 +11248,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193, location); + var node = createNode(196, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10958,12 +11266,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194, location); + var node = createNode(197, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195, location); + var node = createNode(198, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10977,7 +11285,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createTemplateSpan(expression, literal, location) { - var node = createNode(198, location); + var node = createNode(201, location); node.expression = expression; node.literal = literal; return node; @@ -10991,7 +11299,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, location, multiLine, flags) { - var block = createNode(200, location, flags); + var block = createNode(203, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11007,7 +11315,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201, location, flags); + var node = createNode(204, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11022,7 +11330,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220, location, flags); + var node = createNode(223, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11035,7 +11343,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219, location, flags); + var node = createNode(222, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11050,11 +11358,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202, location); + return createNode(205, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203, location, flags); + var node = createNode(206, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11067,7 +11375,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204, location); + var node = createNode(207, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11082,7 +11390,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205, location); + var node = createNode(208, location); node.statement = statement; node.expression = expression; return node; @@ -11096,7 +11404,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206, location); + var node = createNode(209, location); node.expression = expression; node.statement = statement; return node; @@ -11110,7 +11418,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207, location, undefined); + var node = createNode(210, location, undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11126,7 +11434,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208, location); + var node = createNode(211, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11141,7 +11449,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209, location); + var node = createNode(212, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11156,7 +11464,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210, location); + var node = createNode(213, location); if (label) { node.label = label; } @@ -11171,7 +11479,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211, location); + var node = createNode(214, location); if (label) { node.label = label; } @@ -11186,7 +11494,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212, location); + var node = createNode(215, location); node.expression = expression; return node; } @@ -11199,7 +11507,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213, location); + var node = createNode(216, location); node.expression = expression; node.statement = statement; return node; @@ -11213,7 +11521,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214, location); + var node = createNode(217, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11227,7 +11535,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215, location); + var node = createNode(218, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11241,7 +11549,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216, location); + var node = createNode(219, location); node.expression = expression; return node; } @@ -11254,7 +11562,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217, location); + var node = createNode(220, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11269,7 +11577,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228, location); + var node = createNode(231, location); node.clauses = createNodeArray(clauses); return node; } @@ -11282,7 +11590,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(221, location, flags); + var node = createNode(224, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11302,7 +11610,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222, location); + var node = createNode(225, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11320,7 +11628,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231, location); + var node = createNode(234, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11336,7 +11644,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232, location); + var node = createNode(235, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11350,7 +11658,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233, location); + var node = createNode(236, location); node.name = name; return node; } @@ -11363,7 +11671,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234, location); + var node = createNode(237, location); node.elements = createNodeArray(elements); return node; } @@ -11376,7 +11684,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235, location); + var node = createNode(238, location); node.propertyName = propertyName; node.name = name; return node; @@ -11390,7 +11698,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236, location); + var node = createNode(239, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11406,7 +11714,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237, location); + var node = createNode(240, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11422,7 +11730,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238, location); + var node = createNode(241, location); node.elements = createNodeArray(elements); return node; } @@ -11435,7 +11743,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239, location); + var node = createNode(242, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11449,7 +11757,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242, location); + var node = createNode(245, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11464,7 +11772,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243, location); + var node = createNode(246, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11478,7 +11786,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244, location); + var node = createNode(247, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11492,7 +11800,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245, location); + var node = createNode(248, location); node.tagName = tagName; return node; } @@ -11505,7 +11813,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246, location); + var node = createNode(249, location); node.name = name; node.initializer = initializer; return node; @@ -11519,7 +11827,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247, location); + var node = createNode(250, location); node.expression = expression; return node; } @@ -11532,7 +11840,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248, location); + var node = createNode(251, location); node.expression = expression; return node; } @@ -11545,7 +11853,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types, location) { - var node = createNode(251, location); + var node = createNode(254, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11559,7 +11867,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249, location); + var node = createNode(252, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11573,7 +11881,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250, location); + var node = createNode(253, location); node.statements = createNodeArray(statements); return node; } @@ -11586,7 +11894,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252, location); + var node = createNode(255, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11600,7 +11908,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer, location) { - var node = createNode(253, location); + var node = createNode(256, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11615,12 +11923,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254, location); + var node = createNode(257, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function createSpreadAssignment(expression, location) { + var node = createNode(258, location); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); @@ -11628,9 +11942,16 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSpreadAssignment(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpreadAssignment(expression, node), node); + } + return node; + } + ts.updateSpreadAssignment = updateSpreadAssignment; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(256, node, node.flags); + var updated = createNode(260, node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11692,13 +12013,27 @@ var ts; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(287, original); + var node = createNode(291, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + function createEndOfDeclarationMarker(original) { + var node = createNode(294); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + function createMergeDeclarationMarker(original) { + var node = createNode(293); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288, location || original); + var node = createNode(292, location || original); node.expression = expression; node.original = original; return node; @@ -11770,10 +12105,6 @@ var ts; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration(undefined, undefined, createToken(23), name, undefined, undefined, undefined); - } - ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { return createCall(createPropertyAccess(func, "call"), undefined, [ thisArg @@ -11809,7 +12140,20 @@ var ts; react.parent = ts.getParseTreeNode(parent); return react; } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536)); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -11829,9 +12173,21 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), undefined, argumentsList, location); + return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList, location); } - ts.createReactCreateElement = createReactCreateElement; + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function createExportDefault(expression) { + return createExportAssignment(undefined, undefined, false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function createLetStatement(name, initializer, location) { + return createVariableStatement(undefined, createLetDeclarationList([createVariableDeclaration(name, undefined, initializer)]), location); + } + ts.createLetStatement = createLetStatement; function createLetDeclarationList(declarations, location) { return createVariableDeclarationList(declarations, location, 1); } @@ -11903,13 +12259,13 @@ var ts; return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); } function createGeti(target) { - return createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createElementAccess(target, createIdentifier("name"))); + return createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createElementAccess(target, createIdentifier("name"))); } function createSeti(target) { return createArrowFunction(undefined, undefined, [ - createParameter("name"), - createParameter("value") - ], undefined, undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); + createParameter(undefined, undefined, undefined, "name"), + createParameter(undefined, undefined, undefined, "value") + ], undefined, createToken(35), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } function createAdvancedAsyncSuperHelper() { var createCache = createVariableStatement(undefined, createConstDeclarationList([ @@ -11918,20 +12274,20 @@ var ts; var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) ])); - var setter = createSetAccessor(undefined, undefined, "value", [createParameter("v")], createBlock([ + var setter = createSetAccessor(undefined, undefined, "value", [createParameter(undefined, undefined, undefined, "v")], createBlock([ createStatement(createCall(createIdentifier("seti"), undefined, [ createIdentifier("name"), createIdentifier("v") ])) ])); - var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter("name")], undefined, undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ getter, setter ])))))); return createVariableStatement(undefined, createConstDeclarationList([ createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ - createParameter("geti"), - createParameter("seti") + createParameter(undefined, undefined, undefined, "geti"), + createParameter(undefined, undefined, undefined, "seti") ], undefined, createBlock([ createCache, getOrCreateAccessorsForName @@ -11957,13 +12313,13 @@ var ts; case 8: case 9: return false; - case 171: + case 174: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172: + case 175: return target.properties.length > 0; default: return true; @@ -11983,7 +12339,7 @@ var ts; } else { switch (callee.kind) { - case 173: { + case 176: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createPropertyAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.name, callee); @@ -11994,7 +12350,7 @@ var ts; } break; } - case 174: { + case 177: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = createTempVariable(recordTempVariable); target = createElementAccess(createAssignment(thisArg, callee.expression, callee.expression), callee.argumentExpression, callee); @@ -12044,14 +12400,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 150: case 151: + case 152: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253: + case 256: return createExpressionForPropertyAssignment(property, receiver); - case 254: + case 257: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148: + case 149: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12092,6 +12448,59 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 262144); + } + ts.getLocalName = getLocalName; + function isLocalName(node) { + return (getEmitFlags(node) & 262144) !== 0; + } + ts.isLocalName = isLocalName; + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 131072); + } + ts.getExportName = getExportName; + function isExportName(node) { + return (getEmitFlags(node) & 131072) !== 0; + } + ts.isExportName = isExportName; + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name_13 = getMutableClone(node.name); + emitFlags |= getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(name_13, emitFlags); + return name_13; + } + return getGeneratedNameForNode(node); + } + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 1536; + if (!allowComments) + emitFlags |= 49152; + if (emitFlags) + setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } @@ -12153,7 +12562,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 179) { + if (skipped.kind === 182) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12162,15 +12571,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(188, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(188, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(191, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(191, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 191) { + && operand.kind === 194) { return false; } return true; @@ -12209,7 +12618,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 && node.operatorToken.kind === 36) { + if (node.kind === 191 && node.operatorToken.kind === 36) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12226,9 +12635,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175: + case 178: return createParen(expression); - case 176: + case 179: return emittedExpression.arguments ? expression : createParen(expression); @@ -12239,7 +12648,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 || emittedExpression.arguments) + && (emittedExpression.kind !== 179 || emittedExpression.arguments) && emittedExpression.kind !== 8) { return expression; } @@ -12277,7 +12686,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(188, 25); + var commaPrecedence = ts.getOperatorPrecedence(191, 25); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, expression); @@ -12288,7 +12697,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 || kind === 181) { + if (kind === 183 || kind === 184) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12296,7 +12705,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 || leftmostExpressionKind === 180) { + if (leftmostExpressionKind === 175 || leftmostExpressionKind === 183) { return createParen(expression, expression); } } @@ -12314,21 +12723,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187: + case 190: node = node.operand; continue; - case 188: + case 191: node = node.left; continue; - case 189: + case 192: node = node.condition; continue; - case 175: - case 174: - case 173: + case 178: + case 177: + case 176: node = node.expression; continue; - case 288: + case 292: node = node.expression; continue; } @@ -12337,7 +12746,7 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172) { + if (emittedBody.kind === 175) { return createParen(body, body); } return body; @@ -12362,7 +12771,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179) { + while (node.kind === 182) { node = node.expression; } return node; @@ -12376,7 +12785,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288) { + while (node.kind === 292) { node = node.expression; } return node; @@ -12432,7 +12841,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 256) { + if (node.kind === 260) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12522,13 +12931,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_12 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_14 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_14) ? name_14 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 231 && node.importClause) { + if (node.kind === 234 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 && node.moduleSpecifier) { + if (node.kind === 240 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12566,6 +12975,221 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } + function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + context.startLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = addPrologueDirectives(statements, body.statements, false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); + addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 184); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = createReturn(expression, body); + setEmitFlags(returnStatement, 12288 | 1024 | 32768); + statements.push(returnStatement); + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + setEmitFlags(block, 32); + } + if (closeBraceLocation) { + setTokenSourceMapRange(block, 17, closeBraceLocation); + } + setOriginalNode(block, node.body); + return block; + } + ts.transformFunctionBody = transformFunctionBody; + function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { + if (node.transformFlags & 524288 && node.kind !== 184) { + captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + } + } + ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; + function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + setEmitFlags(captureThisStatement, 49152 | 8388608); + setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + ts.captureThisForNode = captureThisForNode; + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 2097152) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_15 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_15)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_15, initializer, visitor, convertObjectRest); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_15, initializer, visitor); + } + } + } + ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { + var temp = getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608)); + } + else if (initializer) { + statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + } + } + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ + createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536), setEmitFlags(initializer, 1536 | getEmitFlags(initializer)), parameter)) + ], parameter), 32 | 1024 | 12288), undefined, parameter); + statement.startsOnNewLine = true; + setEmitFlags(statement, 12288 | 1024 | 8388608); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + var declarationName = getMutableClone(parameter.name); + setEmitFlags(declarationName, 1536); + var expressionName = getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = createLoopVariable(); + statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList([ + createVariableDeclaration(declarationName, undefined, createArrayLiteral([])) + ]), parameter), 8388608)); + var forStatement = createFor(createVariableDeclarationList([ + createVariableDeclaration(temp, undefined, createLiteral(restIndex)) + ], parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), parameter), createPostfixIncrement(temp, parameter), createBlock([ + startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), parameter)) + ])); + setEmitFlags(forStatement, 8388608); + startOnNewLine(forStatement); + statements.push(forStatement); + } + ts.addRestParameterIfNeeded = addRestParameterIfNeeded; + function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = convertObjectRest ? undefined : createLoopVariable(); + var rhsReference = expression.kind === 70 + ? createUniqueName(expression.text) + : createTempVariable(undefined); + var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, undefined, convertObjectRest); + var declarationList = createVariableDeclarationList(declarations, initializer); + setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(createVariableStatement(undefined, declarationList)); + } + else { + statements.push(createVariableStatement(undefined, setOriginalNode(createVariableDeclarationList([ + createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(undefined), undefined, createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + } + } + else { + var assignment = createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, false, context.hoistVariableDeclaration, visitor, convertObjectRest))); + } + else { + assignment.end = initializer.end; + statements.push(createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + setEmitFlags(expression, 1536 | getEmitFlags(expression)); + var body = createBlock(createNodeArray(statements, statementsLocation), bodyLocation); + setEmitFlags(body, 1536 | 12288); + var forStatement; + if (convertObjectRest) { + forStatement = createForOf(createVariableDeclarationList([ + createVariableDeclaration(rhsReference, undefined, undefined, node.expression) + ], node.expression), node.expression, body, node); + } + else { + forStatement = createFor(setEmitFlags(createVariableDeclarationList([ + createVariableDeclaration(counter, undefined, createLiteral(0), ts.moveRangePos(node.expression, -1)), + createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), 16777216), createLessThan(counter, createPropertyAccess(rhsReference, "length"), node.expression), createPostfixIncrement(counter, node.expression), body, node); + } + setEmitFlags(forStatement, 8192); + return forStatement; + } + ts.convertForOf = convertForOf; })(ts || (ts = {})); var ts; (function (ts) { @@ -12574,13 +13198,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256) { + if (kind === 260) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 140) { + else if (kind < 141) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -12616,26 +13240,28 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 140: + case 141: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 142: + case 143: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 254: + case 257: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 143: + case 258: + return visitNode(cbNode, node.expression); + case 144: + case 147: case 146: - case 145: - case 253: - case 219: - case 170: + case 256: + case 222: + case 173: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -12644,24 +13270,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 157: case 158: - case 152: + case 159: case 153: case 154: + case 155: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 180: - case 221: - case 181: + case 152: + case 183: + case 224: + case 184: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -12672,309 +13298,313 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 156: + case 157: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 155: + case 156: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 159: - return visitNode(cbNode, node.exprName); case 160: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 161: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 162: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 163: + return visitNodes(cbNodes, node.elementTypes); case 164: - return visitNodes(cbNodes, node.types); case 165: - return visitNode(cbNode, node.type); - case 167: - return visitNode(cbNode, node.literal); + return visitNodes(cbNodes, node.types); + case 166: case 168: + return visitNode(cbNode, node.type); case 169: - return visitNodes(cbNodes, node.elements); + return visitNode(cbNode, node.objectType) || + visitNode(cbNode, node.indexType); + case 170: + return visitNode(cbNode, node.literal); case 171: - return visitNodes(cbNodes, node.elements); case 172: + return visitNodes(cbNodes, node.elements); + case 174: + return visitNodes(cbNodes, node.elements); + case 175: return visitNodes(cbNodes, node.properties); - case 173: + case 176: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174: + case 177: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175: - case 176: + case 178: + case 179: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177: + case 180: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178: + case 181: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179: - return visitNode(cbNode, node.expression); case 182: return visitNode(cbNode, node.expression); - case 183: - return visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 186: - return visitNode(cbNode, node.operand); - case 191: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 185: return visitNode(cbNode, node.expression); + case 186: + return visitNode(cbNode, node.expression); case 187: + return visitNode(cbNode, node.expression); + case 189: return visitNode(cbNode, node.operand); + case 194: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); case 188: + return visitNode(cbNode, node.expression); + case 190: + return visitNode(cbNode, node.operand); + case 191: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196: + case 199: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197: + case 200: return visitNode(cbNode, node.expression); - case 189: + case 192: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192: + case 195: return visitNode(cbNode, node.expression); - case 200: - case 227: + case 203: + case 230: return visitNodes(cbNodes, node.statements); - case 256: + case 260: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201: + case 204: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220: + case 223: return visitNodes(cbNodes, node.declarations); - case 203: + case 206: return visitNode(cbNode, node.expression); - case 204: + case 207: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205: + case 208: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206: + case 209: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207: + case 210: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 209: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 210: case 211: - return visitNode(cbNode, node.label); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 212: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 213: + case 214: + return visitNode(cbNode, node.label); + case 215: + return visitNode(cbNode, node.expression); + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214: + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228: + case 231: return visitNodes(cbNodes, node.clauses); - case 249: + case 252: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250: + case 253: return visitNodes(cbNodes, node.statements); - case 215: + case 218: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216: + case 219: return visitNode(cbNode, node.expression); - case 217: + case 220: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252: + case 255: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144: + case 145: return visitNode(cbNode, node.expression); - case 222: - case 193: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 223: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNodes(cbNodes, node.heritageClauses) || - visitNodes(cbNodes, node.members); - case 224: - return visitNodes(cbNodes, node.decorators) || - visitNodes(cbNodes, node.modifiers) || - visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); case 225: + case 196: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 255: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); case 226: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNodes(cbNodes, node.heritageClauses) || + visitNodes(cbNodes, node.members); + case 227: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); + case 228: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 259: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 229: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230: + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231: + case 234: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232: + case 235: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229: + case 232: return visitNode(cbNode, node.name); - case 233: + case 236: return visitNode(cbNode, node.name); - case 234: - case 238: - return visitNodes(cbNodes, node.elements); case 237: + case 241: + return visitNodes(cbNodes, node.elements); + case 240: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235: - case 239: + case 238: + case 242: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236: + case 239: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190: + case 193: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198: + case 201: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141: + case 142: return visitNode(cbNode, node.expression); - case 251: + case 254: return visitNodes(cbNodes, node.types); - case 195: + case 198: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241: + case 244: return visitNode(cbNode, node.expression); - case 240: + case 243: return visitNodes(cbNodes, node.decorators); - case 242: + case 245: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243: - case 244: + case 246: + case 247: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246: + case 249: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247: + case 250: + return visitNode(cbNode, node.expression); + case 251: return visitNode(cbNode, node.expression); case 248: - return visitNode(cbNode, node.expression); - case 245: return visitNode(cbNode, node.tagName); - case 257: - return visitNode(cbNode, node.type); case 261: - return visitNodes(cbNodes, node.types); - case 262: - return visitNodes(cbNodes, node.types); - case 260: - return visitNode(cbNode, node.elementType); - case 264: - return visitNode(cbNode, node.type); - case 263: return visitNode(cbNode, node.type); case 265: - return visitNode(cbNode, node.literal); - case 267: - return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); + return visitNodes(cbNodes, node.types); + case 266: + return visitNodes(cbNodes, node.types); + case 264: + return visitNode(cbNode, node.elementType); case 268: return visitNode(cbNode, node.type); + case 267: + return visitNode(cbNode, node.type); case 269: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 270: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.literal); case 271: - return visitNode(cbNode, node.type); + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); case 272: return visitNode(cbNode, node.type); - case 266: + case 273: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 274: + return visitNode(cbNode, node.type); + case 275: + return visitNode(cbNode, node.type); + case 276: + return visitNode(cbNode, node.type); + case 270: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273: + case 277: return visitNodes(cbNodes, node.tags); - case 275: + case 279: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276: + case 280: return visitNode(cbNode, node.typeExpression); - case 277: + case 281: return visitNode(cbNode, node.typeExpression); - case 278: + case 282: return visitNodes(cbNodes, node.typeParameters); - case 279: + case 283: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281: + case 285: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280: + case 284: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288: + case 292: return visitNode(cbNode, node.expression); - case 282: + case 286: return visitNode(cbNode, node.literal); } } @@ -12988,6 +13618,10 @@ var ts; return result; } ts.createSourceFile = createSourceFile; + function parseIsolatedEntityName(text, languageVersion) { + return Parser.parseIsolatedEntityName(text, languageVersion); + } + ts.parseIsolatedEntityName = parseIsolatedEntityName; function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -13010,8 +13644,8 @@ var ts; ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; var Parser; (function (Parser) { - var scanner = ts.createScanner(4, true); - var disallowInAndDecoratorContext = 32768 | 131072; + var scanner = ts.createScanner(5, true); + var disallowInAndDecoratorContext = 65536 | 262144; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -13035,6 +13669,15 @@ var ts; return result; } Parser.parseSourceFile = parseSourceFile; + function parseIsolatedEntityName(content, languageVersion) { + initializeState(content, languageVersion, undefined, 1); + nextToken(); + var entityName = parseEntityName(true); + var isInvalid = token() === 1 && !parseDiagnostics.length; + clearState(); + return isInvalid ? entityName : undefined; + } + Parser.parseIsolatedEntityName = parseIsolatedEntityName; function getLanguageVariant(scriptKind) { return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 ? 1 : 0; } @@ -13050,7 +13693,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 1048576 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -13125,7 +13768,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(256, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(260, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13145,17 +13788,17 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 32768); - } - function setYieldContext(val) { setContextFlag(val, 65536); } - function setDecoratorContext(val) { + function setYieldContext(val) { setContextFlag(val, 131072); } - function setAwaitContext(val) { + function setDecoratorContext(val) { setContextFlag(val, 262144); } + function setAwaitContext(val) { + setContextFlag(val, 524288); + } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; if (contextFlagsToClear) { @@ -13177,41 +13820,41 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(32768, func); + return doOutsideOfContext(65536, func); } function disallowInAnd(func) { - return doInsideOfContext(32768, func); - } - function doInYieldContext(func) { return doInsideOfContext(65536, func); } - function doInDecoratorContext(func) { + function doInYieldContext(func) { return doInsideOfContext(131072, func); } - function doInAwaitContext(func) { + function doInDecoratorContext(func) { return doInsideOfContext(262144, func); } + function doInAwaitContext(func) { + return doInsideOfContext(524288, func); + } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144, func); + return doOutsideOfContext(524288, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 | 262144, func); + return doInsideOfContext(131072 | 524288, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(65536); - } - function inDisallowInContext() { - return inContext(32768); - } - function inDecoratorContext() { return inContext(131072); } - function inAwaitContext() { + function inDisallowInContext() { + return inContext(65536); + } + function inDecoratorContext() { return inContext(262144); } + function inAwaitContext() { + return inContext(524288); + } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); var length = scanner.getTextPos() - start; @@ -13352,7 +13995,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 140 ? new NodeConstructor(kind, pos, pos) : + return kind >= 141 ? new NodeConstructor(kind, pos, pos) : kind === 70 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -13372,7 +14015,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288; + node.flags |= 1048576; } return node; } @@ -13434,7 +14077,7 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(141); + var node = createNode(142); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -13504,9 +14147,11 @@ var ts; case 6: return token() === 20 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || isLiteralPropertyName(); + return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + case 17: + return isLiteralPropertyName(); case 9: - return token() === 20 || isLiteralPropertyName(); + return token() === 20 || token() === 23 || isLiteralPropertyName(); case 7: if (token() === 16) { return lookAhead(isValidHeritageClauseObjectLiteral); @@ -13521,29 +14166,29 @@ var ts; return isIdentifierOrPattern(); case 10: return token() === 25 || token() === 23 || isIdentifierOrPattern(); - case 17: + case 18: return isIdentifier(); case 11: case 15: return token() === 25 || token() === 23 || isStartOfExpression(); case 16: return isStartOfParameter(); - case 18: case 19: - return token() === 25 || isStartOfType(); case 20: - return isHeritageClause(); + return token() === 25 || isStartOfType(); case 21: + return isHeritageClause(); + case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; case 14: return true; - case 22: case 23: - case 25: - return JSDocParser.isJSDocType(); case 24: + case 26: + return JSDocParser.isJSDocType(); + case 25: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -13587,7 +14232,7 @@ var ts; case 6: case 12: case 9: - case 21: + case 22: return token() === 17; case 3: return token() === 17 || token() === 72 || token() === 78; @@ -13595,31 +14240,32 @@ var ts; return token() === 16 || token() === 84 || token() === 107; case 8: return isVariableDeclaratorListTerminator(); - case 17: + case 18: return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; case 11: return token() === 19 || token() === 24; case 15: - case 19: + case 20: case 10: return token() === 21; case 16: + case 17: return token() === 19 || token() === 21; - case 18: + case 19: return token() !== 25; - case 20: + case 21: return token() === 16 || token() === 17; case 13: return token() === 28 || token() === 40; case 14: return token() === 26 && lookAhead(nextTokenIsSlash); - case 22: - return token() === 19 || token() === 55 || token() === 17; case 23: - return token() === 28 || token() === 17; - case 25: - return token() === 21 || token() === 17; + return token() === 19 || token() === 55 || token() === 17; case 24: + return token() === 28 || token() === 17; + case 26: + return token() === 21 || token() === 17; + case 25: return token() === 17; } } @@ -13636,7 +14282,7 @@ var ts; return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 26; kind++) { + for (var kind = 0; kind < 27; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -13687,7 +14333,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 1540096; + var nodeContextFlags = node.flags & 3080192; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -13719,10 +14365,12 @@ var ts; return isReusableVariableDeclaration(node); case 16: return isReusableParameter(node); - case 20: case 17: - case 19: + return false; + case 21: case 18: + case 20: + case 19: case 11: case 12: case 7: @@ -13734,14 +14382,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 149: - case 154: case 150: + case 155: case 151: - case 146: - case 199: + case 152: + case 147: + case 202: return true; - case 148: + case 149: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 70 && methodDeclaration.name.originalKeywordKind === 122; @@ -13753,8 +14401,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249: - case 250: + case 252: + case 253: return true; } } @@ -13763,65 +14411,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221: - case 201: - case 200: + case 224: case 204: case 203: - case 216: - case 212: - case 214: - case 211: - case 210: - case 208: - case 209: case 207: case 206: - case 213: - case 202: - case 217: + case 219: case 215: + case 217: + case 214: + case 213: + case 211: + case 212: + case 210: + case 209: + case 216: case 205: + case 220: case 218: - case 231: - case 230: - case 237: - case 236: - case 226: - case 222: - case 223: + case 208: + case 221: + case 234: + case 233: + case 240: + case 239: + case 229: case 225: - case 224: + case 226: + case 228: + case 227: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255; + return node.kind === 259; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 153: - case 147: case 154: - case 145: - case 152: + case 148: + case 155: + case 146: + case 153: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 219) { + if (node.kind !== 222) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var parameter = node; @@ -13841,6 +14489,7 @@ var ts; case 1: return ts.Diagnostics.Declaration_or_statement_expected; case 2: return ts.Diagnostics.case_or_default_expected; case 3: return ts.Diagnostics.Statement_expected; + case 17: case 4: return ts.Diagnostics.Property_or_signature_expected; case 5: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; case 6: return ts.Diagnostics.Enum_member_expected; @@ -13852,17 +14501,17 @@ var ts; case 12: return ts.Diagnostics.Property_assignment_expected; case 15: return ts.Diagnostics.Expression_or_comma_expected; case 16: return ts.Diagnostics.Parameter_declaration_expected; - case 17: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18: return ts.Diagnostics.Type_argument_expected; - case 19: return ts.Diagnostics.Type_expected; - case 20: return ts.Diagnostics.Unexpected_token_expected; - case 21: return ts.Diagnostics.Identifier_expected; + case 18: return ts.Diagnostics.Type_parameter_declaration_expected; + case 19: return ts.Diagnostics.Type_argument_expected; + case 20: return ts.Diagnostics.Type_expected; + case 21: return ts.Diagnostics.Unexpected_token_expected; + case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; - case 22: return ts.Diagnostics.Parameter_declaration_expected; - case 23: return ts.Diagnostics.Type_argument_expected; - case 25: return ts.Diagnostics.Type_expected; - case 24: return ts.Diagnostics.Property_assignment_expected; + case 23: return ts.Diagnostics.Parameter_declaration_expected; + case 24: return ts.Diagnostics.Type_argument_expected; + case 26: return ts.Diagnostics.Type_expected; + case 25: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -13916,7 +14565,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22)) { - var node = createNode(140, entity.pos); + var node = createNode(141, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -13933,7 +14582,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190); + var template = createNode(193); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -13945,7 +14594,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198); + var span = createNode(201); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17) { @@ -13993,33 +14642,33 @@ var ts; } function parseTypeReference() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(156, typeName.pos); + var node = createNode(157, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(155, lhs.pos); + var node = createNode(156, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(166); + var node = createNode(167); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(159); + var node = createNode(160); parseExpected(102); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(142); + var node = createNode(143); node.name = parseIdentifier(); if (parseOptional(84)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14033,7 +14682,7 @@ var ts; } function parseTypeParameters() { if (token() === 26) { - return parseBracketedList(17, parseTypeParameter, 26, 28); + return parseBracketedList(18, parseTypeParameter, 26, 28); } } function parseParameterType() { @@ -14046,7 +14695,7 @@ var ts; return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; } function parseParameter() { - var node = createNode(143); + var node = createNode(144); if (token() === 98) { node.name = createIdentifier(true, undefined); node.type = parseParameterType(); @@ -14106,7 +14755,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153) { + if (kind === 154) { parseExpected(93); } fillSignature(55, false, false, false, node); @@ -14146,7 +14795,7 @@ var ts; return token() === 55 || token() === 25 || token() === 21; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(154, fullStart); + var node = createNode(155, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16, parseParameter, 20, 21); @@ -14158,7 +14807,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54); if (token() === 18 || token() === 26) { - var method = createNode(147, fullStart); + var method = createNode(148, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14167,7 +14816,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(145, fullStart); + var property = createNode(146, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -14207,10 +14856,10 @@ var ts; } function parseTypeMember() { if (token() === 18 || token() === 26) { - return parseSignatureMember(152); + return parseSignatureMember(153); } if (token() === 93 && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(153); + return parseSignatureMember(154); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -14224,7 +14873,7 @@ var ts; return token() === 18 || token() === 26; } function parseTypeLiteral() { - var node = createNode(160); + var node = createNode(161); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14240,12 +14889,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(162); - node.elementTypes = parseBracketedList(19, parseType, 20, 21); + var node = createNode(163); + node.elementTypes = parseBracketedList(20, parseType, 20, 21); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(165); + var node = createNode(166); parseExpected(18); node.type = parseType(); parseExpected(19); @@ -14253,7 +14902,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(93); } fillSignature(35, false, false, false, node); @@ -14264,7 +14913,7 @@ var ts; return token() === 22 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167); + var node = createNode(170); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -14275,12 +14924,12 @@ var ts; function parseNonArrayType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: - case 136: - case 128: + case 132: + case 121: + case 135: + case 137: + case 129: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: @@ -14317,16 +14966,16 @@ var ts; function isStartOfType() { switch (token()) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: case 98: case 102: - case 128: + case 129: case 16: case 20: case 26: @@ -14351,13 +15000,36 @@ var ts; function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { - parseExpected(21); - var node = createNode(161, type.pos); - node.elementType = type; - type = finishNode(node); + if (isStartOfType()) { + var node = createNode(169, type.pos); + node.objectType = type; + node.indexType = parseType(); + parseExpected(21); + type = finishNode(node); + } + else { + var node = createNode(162, type.pos); + node.elementType = type; + parseExpected(21); + type = finishNode(node); + } } return type; } + function parseTypeOperator(operator) { + var node = createNode(168); + parseExpected(operator); + node.operator = operator; + node.type = parseTypeOperatorOrHigher(); + return finishNode(node); + } + function parseTypeOperatorOrHigher() { + switch (token()) { + case 126: + return parseTypeOperator(126); + } + return parseArrayTypeOrHigher(); + } function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { var type = parseConstituentType(); if (token() === operator) { @@ -14373,10 +15045,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(164, parseArrayTypeOrHigher, 47); + return parseUnionOrIntersectionType(165, parseTypeOperatorOrHigher, 47); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(163, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(164, parseIntersectionTypeOrHigher, 48); } function isStartOfFunctionType() { if (token() === 26) { @@ -14422,7 +15094,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(155, typePredicateVariable.pos); + var node = createNode(156, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14439,14 +15111,14 @@ var ts; } } function parseType() { - return doOutsideOfContext(327680, parseTypeWorker); + return doOutsideOfContext(655360, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(157); + return parseFunctionOrConstructorType(158); } if (token() === 93) { - return parseFunctionOrConstructorType(158); + return parseFunctionOrConstructorType(159); } return parseUnionTypeOrHigher(); } @@ -14565,7 +15237,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191); + var node = createNode(194); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 38 || isStartOfExpression())) { @@ -14581,13 +15253,13 @@ var ts; ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(181, asyncModifier.pos); + node = createNode(184, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181, identifier.pos); + node = createNode(184, identifier.pos); } - var parameter = createNode(143, identifier.pos); + var parameter = createNode(144, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -14721,7 +15393,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181); + var node = createNode(184); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); fillSignature(55, false, isAsync, !allowAmbiguity, node); @@ -14753,7 +15425,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(189, leftOperand.pos); + var node = createNode(192, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14766,7 +15438,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 139; + return t === 91 || t === 140; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -14844,39 +15516,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188, left.pos); + var node = createNode(191, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(196, left.pos); + var node = createNode(199, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182); + var node = createNode(185); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183); + var node = createNode(186); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184); + var node = createNode(187); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14891,7 +15563,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185); + var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14907,7 +15579,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178) { + if (simpleUnaryExpression.kind === 181) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, 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 { @@ -14960,7 +15632,7 @@ var ts; } function parseIncrementExpression() { if (token() === 42 || token() === 43) { - var node = createNode(186); + var node = createNode(189); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14972,7 +15644,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(187, expression.pos); + var node = createNode(190, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14995,7 +15667,7 @@ var ts; if (token() === 18 || token() === 22 || token() === 20) { return expression; } - var node = createNode(173, expression.pos); + var node = createNode(176, expression.pos); node.expression = expression; parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -15017,8 +15689,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 244) { - var node = createNode(242, opening.pos); + if (opening.kind === 247) { + var node = createNode(245, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15028,14 +15700,14 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243); + ts.Debug.assert(opening.kind === 246); result = opening; } if (inExpressionContext && token() === 26) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(188, result.pos); + var badNode = createNode(191, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15088,7 +15760,7 @@ var ts; var attributes = parseList(13, parseJsxAttribute); var node; if (token() === 28) { - node = createNode(244, fullStart); + node = createNode(247, fullStart); scanJsxText(); } else { @@ -15100,7 +15772,7 @@ var ts; parseExpected(28, undefined, false); scanJsxText(); } - node = createNode(243, fullStart); + node = createNode(246, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15111,7 +15783,7 @@ var ts; var expression = token() === 98 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22)) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15119,7 +15791,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248); + var node = createNode(251); parseExpected(16); if (token() !== 17) { node.expression = parseAssignmentExpressionOrHigher(); @@ -15138,7 +15810,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246); + var node = createNode(249); node.name = parseIdentifierName(); if (token() === 57) { switch (scanJsxAttributeValue()) { @@ -15153,7 +15825,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247); + var node = createNode(250); parseExpected(16); parseExpected(23); node.expression = parseExpression(); @@ -15161,7 +15833,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245); + var node = createNode(248); parseExpected(27); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -15174,7 +15846,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178); + var node = createNode(181); parseExpected(26); node.type = parseType(); parseExpected(28); @@ -15185,7 +15857,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22); if (dotToken) { - var propertyAccess = createNode(173, expression.pos); + var propertyAccess = createNode(176, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15193,13 +15865,13 @@ var ts; } if (token() === 50 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197, expression.pos); + var nonNullExpression = createNode(200, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(174, expression.pos); + var indexedAccess = createNode(177, expression.pos); indexedAccess.expression = expression; if (token() !== 21) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -15213,7 +15885,7 @@ var ts; continue; } if (token() === 12 || token() === 13) { - var tagExpression = createNode(177, expression.pos); + var tagExpression = createNode(180, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 ? parseLiteralNode() @@ -15232,7 +15904,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -15240,7 +15912,7 @@ var ts; continue; } else if (token() === 18) { - var callExpr = createNode(175, expression.pos); + var callExpr = createNode(178, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -15259,7 +15931,7 @@ var ts; if (!parseOptional(26)) { return undefined; } - var typeArguments = parseDelimitedList(18, parseType); + var typeArguments = parseDelimitedList(19, parseType); if (!parseExpected(28)) { return undefined; } @@ -15335,28 +16007,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179); + var node = createNode(182); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192); + var node = createNode(195); parseExpected(23); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(194) : + token() === 25 ? createNode(197) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171); + var node = createNode(174); parseExpected(20); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15367,15 +16039,21 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124)) { - return parseAccessorDeclaration(150, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(132)) { return parseAccessorDeclaration(151, fullStart, decorators, modifiers); } + else if (parseContextualModifier(133)) { + return parseAccessorDeclaration(152, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var dotDotDotToken = parseOptionalToken(23); + if (dotDotDotToken) { + var spreadElement = createNode(258, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -15391,7 +16069,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254, fullStart); + var shorthandDeclaration = createNode(257, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57); @@ -15402,7 +16080,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253, fullStart); + var propertyAssignment = createNode(256, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -15412,7 +16090,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172); + var node = createNode(175); parseExpected(16); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15426,7 +16104,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(180); + var node = createNode(183); node.modifiers = parseModifiers(); parseExpected(88); node.asteriskToken = parseOptionalToken(38); @@ -15448,7 +16126,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176); + var node = createNode(179); parseExpected(93); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -15458,7 +16136,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200); + var node = createNode(203); if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15489,12 +16167,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202); + var node = createNode(205); parseExpected(24); return finishNode(node); } function parseIfStatement() { - var node = createNode(204); + var node = createNode(207); parseExpected(89); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15504,7 +16182,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205); + var node = createNode(208); parseExpected(80); node.statement = parseStatement(); parseExpected(105); @@ -15515,7 +16193,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206); + var node = createNode(209); parseExpected(105); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15538,21 +16216,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91)) { - var forInStatement = createNode(208, pos); + var forInStatement = createNode(211, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(139)) { - var forOfStatement = createNode(209, pos); + else if (parseOptional(140)) { + var forOfStatement = createNode(212, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207, pos); + var forStatement = createNode(210, pos); forStatement.initializer = initializer; parseExpected(24); if (token() !== 24 && token() !== 19) { @@ -15570,7 +16248,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 ? 71 : 76); + parseExpected(kind === 214 ? 71 : 76); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15578,7 +16256,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212); + var node = createNode(215); parseExpected(95); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15587,7 +16265,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213); + var node = createNode(216); parseExpected(106); parseExpected(18); node.expression = allowInAnd(parseExpression); @@ -15596,7 +16274,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249); + var node = createNode(252); parseExpected(72); node.expression = allowInAnd(parseExpression); parseExpected(55); @@ -15604,7 +16282,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250); + var node = createNode(253); parseExpected(78); parseExpected(55); node.statements = parseList(3, parseStatement); @@ -15614,12 +16292,12 @@ var ts; return token() === 72 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214); + var node = createNode(217); parseExpected(97); parseExpected(18); node.expression = allowInAnd(parseExpression); parseExpected(19); - var caseBlock = createNode(228, scanner.getStartPos()); + var caseBlock = createNode(231, scanner.getStartPos()); parseExpected(16); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(17); @@ -15627,14 +16305,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(216); + var node = createNode(219); parseExpected(99); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(217); + var node = createNode(220); parseExpected(101); node.tryBlock = parseBlock(false); node.catchClause = token() === 73 ? parseCatchClause() : undefined; @@ -15645,7 +16323,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252); + var result = createNode(255); parseExpected(73); if (parseExpected(18)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15655,7 +16333,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218); + var node = createNode(221); parseExpected(77); parseSemicolon(); return finishNode(node); @@ -15664,13 +16342,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(215, fullStart); + var labeledStatement = createNode(218, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203, fullStart); + var expressionStatement = createNode(206, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -15699,10 +16377,10 @@ var ts; case 82: return true; case 108: - case 135: + case 136: return nextTokenIsIdentifierOnSameLine(); - case 126: case 127: + case 128: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 116: case 119: @@ -15710,13 +16388,13 @@ var ts; case 111: case 112: case 113: - case 129: + case 130: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 138: + case 139: nextToken(); return token() === 16 || token() === 70 || token() === 83; case 90: @@ -15774,16 +16452,16 @@ var ts; case 119: case 123: case 108: - case 126: case 127: - case 135: - case 138: + case 128: + case 136: + case 139: return true; case 113: case 111: case 112: case 114: - case 129: + case 130: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -15822,9 +16500,9 @@ var ts; case 87: return parseForOrForInOrForOfStatement(); case 76: - return parseBreakOrContinueStatement(210); + return parseBreakOrContinueStatement(213); case 71: - return parseBreakOrContinueStatement(211); + return parseBreakOrContinueStatement(214); case 95: return parseReturnStatement(); case 106: @@ -15843,9 +16521,9 @@ var ts; return parseDeclaration(); case 119: case 108: - case 135: - case 126: + case 136: case 127: + case 128: case 123: case 75: case 82: @@ -15856,8 +16534,8 @@ var ts; case 113: case 116: case 114: - case 129: - case 138: + case 130: + case 139: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15880,13 +16558,13 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 135: + case 136: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 138: - case 126: + case 139: case 127: + case 128: return parseModuleDeclaration(fullStart, decorators, modifiers); case 90: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -15903,7 +16581,7 @@ var ts; } default: if (decorators || modifiers) { - var node = createMissingNode(240, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(243, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15924,16 +16602,17 @@ var ts; } function parseArrayBindingElement() { if (token() === 25) { - return createNode(194); + return createNode(197); } - var node = createNode(170); + var node = createNode(173); node.dotDotDotToken = parseOptionalToken(23); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170); + var node = createNode(173); + node.dotDotDotToken = parseOptionalToken(23); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55) { @@ -15948,14 +16627,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168); + var node = createNode(171); parseExpected(16); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(17); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169); + var node = createNode(172); parseExpected(20); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(21); @@ -15974,7 +16653,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219); + var node = createNode(222); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15983,7 +16662,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220); + var node = createNode(223); switch (token()) { case 103: break; @@ -15997,7 +16676,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 139 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16012,7 +16691,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201, fullStart); + var node = createNode(204, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16020,7 +16699,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88); @@ -16033,7 +16712,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(149, pos); + var node = createNode(150, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122); @@ -16042,7 +16721,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(148, fullStart); + var method = createNode(149, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16055,7 +16734,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(146, fullStart); + var property = createNode(147, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16063,7 +16742,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(65536 | 32768, parseNonParameterInitializer); + : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -16096,7 +16775,7 @@ var ts; case 111: case 112: case 114: - case 129: + case 130: return true; default: return false; @@ -16125,7 +16804,7 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 132 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 133 || idToken === 124) { return true; } switch (token()) { @@ -16148,7 +16827,7 @@ var ts; if (!parseOptional(56)) { break; } - var decorator = createNode(144, decoratorStart); + var decorator = createNode(145, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -16205,7 +16884,7 @@ var ts; } function parseClassElement() { if (token() === 24) { - var result = createNode(199); + var result = createNode(202); nextToken(); return finishNode(result); } @@ -16230,16 +16909,16 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_13 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_13, undefined); + var name_16 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_16, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 193); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 196); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 225); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -16268,13 +16947,13 @@ var ts; } function parseHeritageClauses() { if (isHeritageClause()) { - return parseList(20, parseHeritageClause); + return parseList(21, parseHeritageClause); } return undefined; } function parseHeritageClause() { if (token() === 84 || token() === 107) { - var node = createNode(251); + var node = createNode(254); node.token = token(); nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -16283,10 +16962,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195); + var node = createNode(198); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26) { - node.typeArguments = parseBracketedList(18, parseType, 26, 28); + node.typeArguments = parseBracketedList(19, parseType, 26, 28); } return finishNode(node); } @@ -16297,7 +16976,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223, fullStart); + var node = createNode(226, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108); @@ -16308,10 +16987,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224, fullStart); + var node = createNode(227, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135); + parseExpected(136); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57); @@ -16320,13 +16999,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(255, scanner.getStartPos()); + var node = createNode(259, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82); @@ -16341,7 +17020,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227, scanner.getStartPos()); + var node = createNode(230, scanner.getStartPos()); if (parseExpected(16)) { node.statements = parseList(1, parseStatement); parseExpected(17); @@ -16352,7 +17031,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; @@ -16364,10 +17043,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226, fullStart); + var node = createNode(229, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138) { + if (token() === 139) { node.name = parseIdentifier(); node.flags |= 512; } @@ -16384,14 +17063,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 138) { + if (token() === 139) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(127)) { + else if (parseOptional(128)) { flags |= 16; } else { - parseExpected(126); + parseExpected(127); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -16399,7 +17078,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 && + return token() === 131 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -16409,11 +17088,11 @@ var ts; return nextToken() === 40; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229, fullStart); + var exportDeclaration = createNode(232, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117); - parseExpected(127); + parseExpected(128); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); @@ -16424,8 +17103,8 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 137) { - var importEqualsDeclaration = createNode(230, fullStart); + if (token() !== 25 && token() !== 138) { + var importEqualsDeclaration = createNode(233, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -16435,27 +17114,27 @@ var ts; return addJSDocComment(finishNode(importEqualsDeclaration)); } } - var importDeclaration = createNode(231, fullStart); + var importDeclaration = createNode(234, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || token() === 38 || token() === 16) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137); + parseExpected(138); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(232, fullStart); + var importClause = createNode(235, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(234); + importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(237); } return finishNode(importClause); } @@ -16465,8 +17144,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(241); - parseExpected(130); + var node = createNode(244); + parseExpected(131); parseExpected(18); node.expression = parseModuleSpecifier(); parseExpected(19); @@ -16483,7 +17162,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(233); + var namespaceImport = createNode(236); parseExpected(38); parseExpected(117); namespaceImport.name = parseIdentifier(); @@ -16491,14 +17170,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(21, kind === 234 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 237 ? parseImportSpecifier : parseExportSpecifier, 16, 17); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239); + return parseImportOrExportSpecifier(242); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235); + return parseImportOrExportSpecifier(238); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16517,23 +17196,23 @@ var ts; else { node.name = identifierName; } - if (kind === 235 && checkIdentifierIsKeyword) { + if (kind === 238 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(237, fullStart); + var node = createNode(240, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38)) { - parseExpected(137); + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(238); - if (token() === 137 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(137); + node.exportClause = parseNamedImportsOrExports(241); + if (token() === 138 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(138); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16541,7 +17220,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236, fullStart); + var node = createNode(239, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57)) { @@ -16620,10 +17299,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 230 && node.moduleReference.kind === 241 - || node.kind === 231 - || node.kind === 236 - || node.kind === 237 + || node.kind === 233 && node.moduleReference.kind === 244 + || node.kind === 234 + || node.kind === 239 + || node.kind === 240 ? node : undefined; }); @@ -16648,8 +17327,8 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState(content, 4, undefined, 1); - sourceFile = createSourceFile("file.js", 4, 1); + initializeState(content, 5, undefined, 1); + sourceFile = createSourceFile("file.js", 5, 1); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -16659,7 +17338,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(257, scanner.getTokenPos()); + var result = createNode(261, scanner.getTokenPos()); parseExpected(16); result.type = parseJSDocTopLevelType(); parseExpected(17); @@ -16670,12 +17349,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48) { - var unionType = createNode(261, type.pos); + var unionType = createNode(265, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57) { - var optionalType = createNode(268, type.pos); + var optionalType = createNode(272, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -16686,20 +17365,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20) { - var arrayType = createNode(260, type.pos); + var arrayType = createNode(264, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21); type = finishNode(arrayType); } else if (token() === 54) { - var nullableType = createNode(263, type.pos); + var nullableType = createNode(267, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50) { - var nonNullableType = createNode(264, type.pos); + var nonNullableType = createNode(268, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -16733,14 +17412,14 @@ var ts; case 98: return parseJSDocThisType(); case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: case 94: - case 136: - case 128: + case 137: + case 129: return parseTokenNode(); case 9: case 8: @@ -16751,30 +17430,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272); + var result = createNode(276); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271); + var result = createNode(275); nextToken(); parseExpected(55); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269); + var result = createNode(273); nextToken(); parseExpected(18); - result.parameters = parseDelimitedList(22, parseJSDocParameter); + result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19); if (token() === 55) { @@ -16784,7 +17463,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(143); + var parameter = createNode(144); parameter.type = parseJSDocType(); if (parseOptional(57)) { parameter.questionToken = createNode(57); @@ -16792,7 +17471,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267); + var result = createNode(271); result.name = parseSimplePropertyName(); if (token() === 26) { result.typeArguments = parseTypeArguments(); @@ -16812,7 +17491,7 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(23, parseJSDocType); + var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28); @@ -16826,26 +17505,26 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(140, left.pos); + var result = createNode(141, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(265); + var result = createNode(269); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264); + var result = createNode(268); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262); + var result = createNode(266); nextToken(); - result.types = parseDelimitedList(25, parseJSDocType); + result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21); return finishNode(result); @@ -16857,7 +17536,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261); + var result = createNode(265); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19); @@ -16873,12 +17552,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258); + var result = createNode(262); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282); + var result = createNode(286); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -16891,17 +17570,17 @@ var ts; token() === 28 || token() === 57 || token() === 48) { - var result = createNode(259, pos); + var result = createNode(263, pos); return finishNode(result); } else { - var result = createNode(263, pos); + var result = createNode(267, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState(content, 4, undefined, 1); + initializeState(content, 5, undefined, 1); sourceFile = { languageVariant: 0, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -17034,7 +17713,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(273, start); + var result = createNode(277, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17141,7 +17820,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274, atToken.pos); + var result = createNode(278, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17196,7 +17875,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275, atToken.pos); + var result = createNode(279, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17207,20 +17886,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 276; })) { + if (ts.forEach(tags, function (t) { return t.kind === 280; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276, atToken.pos); + var result = createNode(280, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 277; })) { + if (ts.forEach(tags, function (t) { return t.kind === 281; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -17235,7 +17914,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -17245,7 +17924,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279, atToken.pos); + var typedefTag = createNode(283, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -17259,11 +17938,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267) { + if (typeExpression.type.kind === 271) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_14 = jsDocTypeReference.name; - if (name_14.text === "Object") { + var name_17 = jsDocTypeReference.name; + if (name_17.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17277,7 +17956,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(285, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -17318,7 +17997,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(226, pos); + var jsDocNamespaceNode = createNode(229, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -17362,19 +18041,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 278; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_15 = parseJSDocIdentifierName(); + var name_18 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_15) { + if (!name_18) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(142, name_15.pos); - typeParameter.name = name_15; + var typeParameter = createNode(143, name_18.pos); + typeParameter.name = name_18; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -17385,7 +18064,7 @@ var ts; break; } } - var result = createNode(278, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -17704,16 +18383,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 223 || node.kind === 224) { + if (node.kind === 226 || node.kind === 227) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 231 || node.kind === 230) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 234 || node.kind === 233) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 227) { + else if (node.kind === 230) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -17729,7 +18408,7 @@ var ts; }); return state_1; } - else if (node.kind === 226) { + else if (node.kind === 229) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } @@ -17838,7 +18517,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 229)) { symbol.valueDeclaration = node; } } @@ -17848,7 +18527,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 141) { + if (node.name.kind === 142) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -17859,21 +18538,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 149: + case 150: return "__constructor"; - case 157: - case 152: - return "__call"; case 158: case 153: - return "__new"; + return "__call"; + case 159: case 154: + return "__new"; + case 155: return "__index"; - case 237: + case 240: return "__export"; - case 236: + case 239: return node.isExportEquals ? "export=" : "default"; - case 188: + case 191: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; @@ -17885,20 +18564,20 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221: - case 222: + case 224: + case 225: return ts.hasModifier(node, 512) ? "default" : undefined; - case 269: + case 273: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143: - ts.Debug.assert(node.parent.kind === 269); + case 144: + ts.Debug.assert(node.parent.kind === 273); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279: + case 283: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 204) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -17942,7 +18621,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 236 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 239 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17962,7 +18641,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 239 || (node.kind === 230 && hasExportModifier)) { + if (node.kind === 242 || (node.kind === 233 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17970,7 +18649,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 279 && + var isJSDocTypedefInJSDocNamespace = node.kind === 283 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18009,7 +18688,7 @@ var ts; var saveReturnTarget = currentReturnTarget; var saveActiveLabels = activeLabels; var saveHasExplicitReturn = hasExplicitReturn; - var isIIFE = containerFlags & 16 && !!ts.getImmediatelyInvokedFunctionExpression(node); + var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) && !!ts.getImmediatelyInvokedFunctionExpression(node); if (isIIFE) { currentReturnTarget = createBranchLabel(); } @@ -18025,13 +18704,13 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~32128; + node.flags &= ~64896; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 256) { + if (node.kind === 260) { node.flags |= emitFlags; } if (isIIFE) { @@ -18084,64 +18763,64 @@ var ts; return; } switch (node.kind) { - case 206: + case 209: bindWhileStatement(node); break; - case 205: + case 208: bindDoStatement(node); break; - case 207: + case 210: bindForStatement(node); break; - case 208: - case 209: + case 211: + case 212: bindForInOrForOfStatement(node); break; - case 204: + case 207: bindIfStatement(node); break; - case 212: - case 216: + case 215: + case 219: bindReturnOrThrow(node); break; - case 211: - case 210: + case 214: + case 213: bindBreakOrContinueStatement(node); break; - case 217: + case 220: bindTryStatement(node); break; - case 214: + case 217: bindSwitchStatement(node); break; - case 228: + case 231: bindCaseBlock(node); break; - case 249: + case 252: bindCaseClause(node); break; - case 215: + case 218: bindLabeledStatement(node); break; - case 186: + case 189: bindPrefixUnaryExpressionFlow(node); break; - case 187: + case 190: bindPostfixUnaryExpressionFlow(node); break; - case 188: + case 191: bindBinaryExpressionFlow(node); break; - case 182: + case 185: bindDeleteExpressionFlow(node); break; - case 189: + case 192: bindConditionalExpressionFlow(node); break; - case 219: + case 222: bindVariableDeclarationFlow(node); break; - case 175: + case 178: bindCallExpressionFlow(node); break; default: @@ -18153,15 +18832,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return isNarrowableReference(expr); - case 175: + case 178: return hasNarrowableArgument(expr); - case 179: + case 182: return isNarrowingExpression(expr.expression); - case 188: + case 191: return isNarrowingBinaryExpression(expr); - case 186: + case 189: return expr.operator === 50 && isNarrowingExpression(expr.operand); } return false; @@ -18169,7 +18848,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 || expr.kind === 98 || - expr.kind === 173 && isNarrowableReference(expr.expression); + expr.kind === 176 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -18180,14 +18859,14 @@ var ts; } } } - if (expr.expression.kind === 173 && + if (expr.expression.kind === 176 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 183 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 186 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -18208,9 +18887,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179: + case 182: return isNarrowableOperand(expr.expression); - case 188: + case 191: switch (expr.operatorToken.kind) { case 57: return isNarrowableOperand(expr.left); @@ -18304,33 +18983,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204: - case 206: - case 205: - return parent.expression === node; case 207: - case 189: + case 209: + case 208: + return parent.expression === node; + case 210: + case 192: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179) { + if (node.kind === 182) { node = node.expression; } - else if (node.kind === 186 && node.operator === 50) { + else if (node.kind === 189 && node.operator === 50) { node = node.operand; } else { - return node.kind === 188 && (node.operatorToken.kind === 52 || + return node.kind === 191 && (node.operatorToken.kind === 52 || node.operatorToken.kind === 53); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 || - node.parent.kind === 186 && + while (node.parent.kind === 182 || + node.parent.kind === 189 && node.parent.operator === 50) { node = node.parent; } @@ -18372,8 +19051,11 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 218 + ? ts.lastOrUndefined(activeLabels) + : undefined; + var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); + var postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel(); addAntecedent(preDoLabel, currentFlow); currentFlow = preDoLabel; bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); @@ -18404,7 +19086,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220) { + if (node.initializer.kind !== 223) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18426,7 +19108,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212) { + if (node.kind === 215) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18446,7 +19128,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 ? breakTarget : continueTarget; + var flowLabel = node.kind === 214 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18503,7 +19185,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 250; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 253; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -18564,11 +19246,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); + if (!node.statement || node.statement.kind !== 208) { + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 && node.operatorToken.kind === 57) { + if (node.kind === 191 && node.operatorToken.kind === 57) { bindAssignmentTargetFlow(node.left); } else { @@ -18579,10 +19263,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171) { + else if (node.kind === 174) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192) { + if (e.kind === 195) { bindAssignmentTargetFlow(e.expression); } else { @@ -18590,15 +19274,18 @@ var ts; } } } - else if (node.kind === 172) { + else if (node.kind === 175) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253) { + if (p.kind === 256) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254) { + else if (p.kind === 257) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 258) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -18650,9 +19337,9 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 57 && !ts.isAssignmentTarget(node)) { + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (node.left.kind === 174) { + if (operator === 57 && node.left.kind === 177) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18663,7 +19350,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { bindAssignmentTargetFlow(node.expression); } } @@ -18673,9 +19360,11 @@ var ts; var postExpressionLabel = createBranchLabel(); bindCondition(node.condition, trueLabel, falseLabel); currentFlow = finishFlowLabel(trueLabel); + bind(node.questionToken); bind(node.whenTrue); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(falseLabel); + bind(node.colonToken); bind(node.whenFalse); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(postExpressionLabel); @@ -18694,16 +19383,16 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 208 || node.parent.parent.kind === 209) { + if (node.initializer || node.parent.parent.kind === 211 || node.parent.parent.kind === 212) { bindInitializedVariableFlow(node); } } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 179) { + while (expr.kind === 182) { expr = expr.expression; } - if (expr.kind === 180 || expr.kind === 181) { + if (expr.kind === 183 || expr.kind === 184) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -18711,7 +19400,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173) { + if (node.expression.kind === 176) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18720,51 +19409,51 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193: - case 222: + case 196: case 225: - case 172: - case 160: - case 281: - case 265: - return 1; - case 223: - return 1 | 64; + case 228: + case 175: + case 161: + case 285: case 269: + return 1; case 226: - case 224: + return 1 | 64; + case 273: + case 229: + case 227: return 1 | 32; - case 256: + case 260: return 1 | 4 | 32; - case 148: + case 149: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 149: - case 221: - case 147: case 150: + case 224: + case 148: case 151: case 152: case 153: case 154: - case 157: + case 155: case 158: + case 159: return 1 | 4 | 32 | 8; - case 180: - case 181: + case 183: + case 184: return 1 | 4 | 32 | 8 | 16; - case 227: + case 230: return 4; - case 146: + case 147: return node.initializer ? 4 : 0; - case 252: - case 207: - case 208: - case 209: - case 228: + case 255: + case 210: + case 211: + case 212: + case 231: return 2; - case 200: + case 203: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18780,36 +19469,36 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 226: + case 229: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256: + case 260: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193: - case 222: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 196: case 225: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 228: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160: - case 172: - case 223: - case 265: - case 281: + case 161: + case 175: + case 226: + case 269: + case 285: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 157: case 158: - case 152: + case 159: case 153: case 154: - case 148: - case 147: + case 155: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 269: + case 152: case 224: + case 183: + case 184: + case 273: + case 227: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18824,11 +19513,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 256 ? node : node.body; - if (body && (body.kind === 256 || body.kind === 227)) { + var body = node.kind === 260 ? node : node.body; + if (body && (body.kind === 260 || body.kind === 230)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 237 || stat.kind === 236) { + if (stat.kind === 240 || stat.kind === 239) { return true; } } @@ -18904,11 +19593,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 70) { + if (prop.kind === 258 || prop.name.kind !== 70) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 253 || prop.kind === 254 || prop.kind === 148 + var currentKind = prop.kind === 256 || prop.kind === 257 || prop.kind === 149 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -18930,10 +19619,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226: + case 229: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256: + case 260: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19023,8 +19712,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 256 && - blockScopeContainer.kind !== 226 && + if (blockScopeContainer.kind !== 260 && + blockScopeContainer.kind !== 229 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -19067,7 +19756,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 139) { + if (node.kind > 140) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -19107,23 +19796,23 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 279) { + while (parentNode && parentNode.kind !== 283) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 254)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 257)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173: + case 176: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188: + case 191: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -19146,115 +19835,131 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252: + case 255: return checkStrictModeCatchClause(node); - case 182: + case 185: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 187: + case 190: return checkStrictModePostfixUnaryExpression(node); - case 186: + case 189: return checkStrictModePrefixUnaryExpression(node); - case 213: + case 216: return checkStrictModeWithStatement(node); - case 166: + case 167: seenThisKeyword = true; return; - case 155: + case 156: return checkTypePredicate(node); - case 142: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 143: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 144: return bindParameter(node); - case 219: - case 170: + case 222: + case 173: + if (node.dotDotDotToken && node.parent.kind === 171) { + emitFlags |= 32768; + } return bindVariableDeclarationOrBindingElement(node); + case 147: case 146: - case 145: - case 266: + case 270: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 280: + case 284: return bindJSDocProperty(node); - case 253: - case 254: + case 256: + case 257: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 255: + case 259: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 247: - emitFlags |= 16384; + case 258: + case 250: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 175 && + root.parent.kind === 191 && + root.parent.operatorToken.kind === 57 && + root.parent.left === root) { + hasRest = true; + break; + } + root = root.parent; + } + emitFlags |= hasRest ? 32768 : 16384; return; - case 152: case 153: case 154: + case 155: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 148: - case 147: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 221: - return bindFunctionDeclaration(node); case 149: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 148: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 224: + return bindFunctionDeclaration(node); case 150: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 151: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 152: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 157: case 158: - case 269: + case 159: + case 273: return bindFunctionOrConstructorType(node); - case 160: - case 281: - case 265: + case 161: + case 285: + case 269: return bindAnonymousDeclaration(node, 2048, "__type"); - case 172: - return bindObjectLiteralExpression(node); - case 180: - case 181: - return bindFunctionExpression(node); case 175: + return bindObjectLiteralExpression(node); + case 183: + case 184: + return bindFunctionExpression(node); + case 178: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 193: - case 222: + case 196: + case 225: inStrictMode = true; return bindClassLikeDeclaration(node); - case 223: + case 226: return bindBlockScopedDeclaration(node, 64, 792968); - case 279: + case 283: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 224: + case 227: return bindBlockScopedDeclaration(node, 524288, 793064); - case 225: + case 228: return bindEnumDeclaration(node); - case 226: - return bindModuleDeclaration(node); - case 230: - case 233: - case 235: - case 239: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); case 229: - return bindNamespaceExportDeclaration(node); - case 232: - return bindImportClause(node); - case 237: - return bindExportDeclaration(node); + return bindModuleDeclaration(node); + case 233: case 236: + case 238: + case 242: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 232: + return bindNamespaceExportDeclaration(node); + case 235: + return bindImportClause(node); + case 240: + return bindExportDeclaration(node); + case 239: return bindExportAssignment(node); - case 256: + case 260: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200: + case 203: if (!ts.isFunctionLike(node.parent)) { return; } - case 227: + case 230: return updateStrictModeStatementList(node.statements); } } @@ -19263,7 +19968,7 @@ var ts; if (parameterName && parameterName.kind === 70) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166) { + if (parameterName && parameterName.kind === 167) { seenThisKeyword = true; } bind(type); @@ -19282,7 +19987,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 236 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 239 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -19292,17 +19997,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 256) { + if (node.parent.kind !== 260) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_7 = node.parent; - if (!ts.isExternalModule(parent_7)) { + var parent_6 = node.parent; + if (!ts.isExternalModule(parent_6)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_7.isDeclarationFile) { + if (!parent_6.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -19341,11 +20046,11 @@ var ts; } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 221 || container.kind === 180) { + if (container.kind === 224 || container.kind === 183) { container.symbol.members = container.symbol.members || ts.createMap(); declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); } - else if (container.kind === 149) { + else if (container.kind === 150) { var saveContainer = container; container = container.parent; var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); @@ -19385,7 +20090,7 @@ var ts; emitFlags |= 2048; } } - if (node.kind === 222) { + if (node.kind === 225) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -19503,15 +20208,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 202) || - node.kind === 222 || - (node.kind === 226 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 225 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 205) || + node.kind === 225 || + (node.kind === 229 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 228 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 || + (node.kind !== 204 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -19525,56 +20230,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175: + case 178: return computeCallExpression(node, subtreeFlags); - case 176: - return computeNewExpression(node, subtreeFlags); - case 226: - return computeModuleDeclaration(node, subtreeFlags); case 179: + return computeNewExpression(node, subtreeFlags); + case 229: + return computeModuleDeclaration(node, subtreeFlags); + case 182: return computeParenthesizedExpression(node, subtreeFlags); - case 188: + case 191: return computeBinaryExpression(node, subtreeFlags); - case 203: + case 206: return computeExpressionStatement(node, subtreeFlags); - case 143: + case 144: return computeParameter(node, subtreeFlags); - case 181: + case 184: return computeArrowFunction(node, subtreeFlags); - case 180: + case 183: return computeFunctionExpression(node, subtreeFlags); - case 221: + case 224: return computeFunctionDeclaration(node, subtreeFlags); - case 219: - return computeVariableDeclaration(node, subtreeFlags); - case 220: - return computeVariableDeclarationList(node, subtreeFlags); - case 201: - return computeVariableStatement(node, subtreeFlags); - case 215: - return computeLabeledStatement(node, subtreeFlags); case 222: + return computeVariableDeclaration(node, subtreeFlags); + case 223: + return computeVariableDeclarationList(node, subtreeFlags); + case 204: + return computeVariableStatement(node, subtreeFlags); + case 218: + return computeLabeledStatement(node, subtreeFlags); + case 225: return computeClassDeclaration(node, subtreeFlags); - case 193: + case 196: return computeClassExpression(node, subtreeFlags); - case 251: + case 254: return computeHeritageClause(node, subtreeFlags); - case 252: + case 255: return computeCatchClause(node, subtreeFlags); - case 195: + case 198: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149: - return computeConstructor(node, subtreeFlags); - case 146: - return computePropertyDeclaration(node, subtreeFlags); - case 148: - return computeMethod(node, subtreeFlags); case 150: + return computeConstructor(node, subtreeFlags); + case 147: + return computePropertyDeclaration(node, subtreeFlags); + case 149: + return computeMethod(node, subtreeFlags); case 151: + case 152: return computeAccessor(node, subtreeFlags); - case 230: + case 233: return computeImportEquals(node, subtreeFlags); - case 173: + case 176: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19588,19 +20293,19 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576 + if (subtreeFlags & 8388608 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function isSuperOrSuperProperty(node, kind) { switch (kind) { case 96: return true; - case 173: - case 174: + case 176: + case 177: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96; @@ -19612,27 +20317,28 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 1048576) { - transformFlags |= 768; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~537922901; + return transformFlags & ~545281365; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 - && (leftKind === 172 - || leftKind === 171)) { - transformFlags |= 768 | 1024; + if (operatorTokenKind === 57 && leftKind === 175) { + transformFlags |= 48 | 3072 | 49152; + } + else if (operatorTokenKind === 57 && leftKind === 174) { + transformFlags |= 3072 | 49152; } else if (operatorTokenKind === 39 || operatorTokenKind === 61) { - transformFlags |= 192; + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19642,33 +20348,36 @@ var ts; var dotDotDotToken = node.dotDotDotToken; if (node.questionToken || node.type - || subtreeFlags & 8192 + || subtreeFlags & 65536 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 524288; + transformFlags |= 3 | 4194304; } - if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { - transformFlags |= 768 | 262144; + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + if (subtreeFlags & 67108864 || initializer || dotDotDotToken) { + transformFlags |= 3072 | 2097152; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 196 - || expressionKind === 178) { + if (expressionKind === 199 + || expressionKind === 181) { transformFlags |= 3; } - if (expressionTransformFlags & 1024) { - transformFlags |= 1024; + if (expressionTransformFlags & 16384) { + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -19677,36 +20386,35 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 768; - if ((subtreeFlags & 548864) - || (modifierFlags & 1) + transformFlags = subtreeFlags | 3072; + if ((subtreeFlags & 4390912) || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; - if (subtreeFlags & 548864 + var transformFlags = subtreeFlags | 3072; + if (subtreeFlags & 4390912 || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 131072) { - transformFlags |= 32768; + if (subtreeFlags & 1048576) { + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~539749717; + return transformFlags & ~559895893; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84: - transformFlags |= 768; + transformFlags |= 3072; break; case 107: transformFlags |= 3; @@ -19716,23 +20424,23 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19741,10 +20449,10 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (node.decorators || ts.hasModifier(node, 2270) || node.typeParameters @@ -19753,13 +20461,13 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 48; + transformFlags |= 192; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19770,15 +20478,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~591760725; + return transformFlags & ~975983957; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 16384; + transformFlags |= 131072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -19788,27 +20496,27 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 33554432; - if (modifierFlags & 1) { - transformFlags |= 3 | 768; - } + transformFlags = subtreeFlags | 268435456; if (modifierFlags & 2270 || node.typeParameters || node.type) { transformFlags |= 3; } if (modifierFlags & 256) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19818,54 +20526,63 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 327680) { - transformFlags |= 768; + if (subtreeFlags & 2621440) { + transformFlags |= 3072; } if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 6144; + transformFlags |= 12288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592293205; + return transformFlags & ~980243797; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 768; + var transformFlags = subtreeFlags | 3072; if (ts.hasModifier(node, 2270) || node.typeParameters || node.type) { transformFlags |= 3; } if (ts.hasModifier(node, 256)) { + transformFlags |= 192; + } + if (subtreeFlags & 8388608) { transformFlags |= 48; } - if (subtreeFlags & 32768) { - transformFlags |= 65536; + if (subtreeFlags & 262144) { + transformFlags |= 524288; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~592227669; + return transformFlags & ~979719509; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; if (expressionKind === 96) { - transformFlags |= 32768; + transformFlags |= 262144; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - if (nameKind === 168 || nameKind === 169) { - transformFlags |= 768 | 8388608; + if (nameKind === 171) { + transformFlags |= 48 | 3072 | 67108864; + } + else if (nameKind === 172) { + transformFlags |= 3072 | 67108864; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -19876,24 +20593,21 @@ var ts; } else { transformFlags = subtreeFlags; - if (modifierFlags & 1) { - transformFlags |= 768 | 3; - } - if (declarationListTransformFlags & 8388608) { - transformFlags |= 768; + if (declarationListTransformFlags & 67108864) { + transformFlags |= 3072; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 4194304 + if (subtreeFlags & 33554432 && ts.isIterationStatement(node, true)) { - transformFlags |= 768; + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -19901,15 +20615,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 1024) { - transformFlags |= 768; + if (node.expression.transformFlags & 16384) { + transformFlags |= 3072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536874325; + return transformFlags & ~536892757; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -19918,26 +20632,26 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~574729557; + return transformFlags & ~839734613; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 33554432; - if (subtreeFlags & 8388608) { - transformFlags |= 768; + var transformFlags = subtreeFlags | 268435456; + if (subtreeFlags & 67108864) { + transformFlags |= 3072; } if (node.flags & 3) { - transformFlags |= 768 | 4194304; + transformFlags |= 3072 | 33554432; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545262933; + return transformFlags & ~604001621; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536874325; + var excludeFlags = 536892757; switch (kind) { case 119: - case 185: - transformFlags |= 48; + case 188: + transformFlags |= 192; break; case 113: case 111: @@ -19945,52 +20659,49 @@ var ts; case 116: case 123: case 75: - case 225: - case 255: - case 178: - case 196: - case 197: - case 129: + case 228: + case 259: + case 181: + case 199: + case 200: + case 130: transformFlags |= 3; break; - case 242: - case 243: - case 244: - case 10: case 245: case 246: case 247: + case 10: case 248: + case 249: + case 250: + case 251: transformFlags |= 12; break; - case 83: - transformFlags |= 768 | 3; - break; - case 78: + case 212: + transformFlags |= 48; case 12: case 13: case 14: case 15: - case 190: - case 177: - case 254: - case 209: - transformFlags |= 768; + case 193: + case 180: + case 257: + case 114: + transformFlags |= 3072; break; - case 191: - transformFlags |= 768 | 16777216; + case 194: + transformFlags |= 3072 | 134217728; break; case 118: - case 131: - case 128: - case 133: - case 121: + case 132: + case 129: case 134: + case 121: + case 135: case 104: - case 142: - case 145: - case 147: - case 152: + case 143: + case 146: + case 148: case 153: case 154: case 155: @@ -20004,122 +20715,138 @@ var ts; case 163: case 164: case 165: - case 223: - case 224: case 166: + case 226: + case 227: case 167: + case 168: + case 169: + case 170: transformFlags = 3; excludeFlags = -3; break; - case 141: - transformFlags |= 2097152; - if (subtreeFlags & 32768) { - transformFlags |= 131072; + case 142: + transformFlags |= 16777216; + if (subtreeFlags & 262144) { + transformFlags |= 1048576; } break; - case 192: - transformFlags |= 1048576; + case 195: + case 258: + transformFlags |= 8388608; break; + case 173: + if (node.dotDotDotToken) { + transformFlags |= 8388608; + } case 96: - transformFlags |= 768; + transformFlags |= 3072; break; case 98: - transformFlags |= 32768; - break; - case 168: - case 169: - transformFlags |= 768 | 8388608; - break; - case 144: - transformFlags |= 3 | 8192; - break; - case 172: - excludeFlags = 539110741; - if (subtreeFlags & 2097152) { - transformFlags |= 768; - } - if (subtreeFlags & 131072) { - transformFlags |= 32768; - } + transformFlags |= 262144; break; case 171: - case 176: - excludeFlags = 537922901; + case 172: + if (subtreeFlags & 8388608) { + transformFlags |= 48 | 67108864; + } + else { + transformFlags |= 3072 | 67108864; + } + break; + case 145: + transformFlags |= 3 | 65536; + break; + case 175: + excludeFlags = 554784085; + if (subtreeFlags & 16777216) { + transformFlags |= 3072; + } if (subtreeFlags & 1048576) { - transformFlags |= 768; + transformFlags |= 262144; + } + if (subtreeFlags & 8388608) { + transformFlags |= 48; + } + break; + case 174: + case 179: + excludeFlags = 545281365; + if (subtreeFlags & 8388608) { + transformFlags |= 3072; } break; - case 205: - case 206: - case 207: case 208: - if (subtreeFlags & 4194304) { - transformFlags |= 768; - } - break; - case 256: - if (subtreeFlags & 65536) { - transformFlags |= 768; - } - break; - case 212: + case 209: case 210: case 211: - transformFlags |= 33554432; + if (subtreeFlags & 33554432) { + transformFlags |= 3072; + } + break; + case 260: + if (subtreeFlags & 524288) { + transformFlags |= 3072; + } + break; + case 215: + case 213: + case 214: + transformFlags |= 268435456; break; } node.transformFlags = transformFlags | 536870912; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 && kind <= 167) { + if (kind >= 156 && kind <= 170) { return -3; } switch (kind) { - case 175: - case 176: - case 171: - return 537922901; - case 226: - return 574729557; - case 143: - return 545262933; - case 181: - return 592227669; - case 180: - case 221: - return 592293205; - case 220: - return 545262933; - case 222: - case 193: - return 539749717; - case 149: - return 591760725; - case 148: + case 178: + case 179: + case 174: + return 545281365; + case 229: + return 839734613; + case 144: + return 604001621; + case 184: + return 979719509; + case 183: + case 224: + return 980243797; + case 223: + return 604001621; + case 225: + case 196: + return 559895893; case 150: + return 975983957; + case 149: case 151: - return 591760725; - case 118: - case 131: - case 128: - case 133: - case 121: - case 134: - case 104: - case 142: - case 145: - case 147: case 152: + return 975983957; + case 118: + case 132: + case 129: + case 134: + case 121: + case 135: + case 104: + case 143: + case 146: + case 148: case 153: case 154: - case 223: - case 224: + case 155: + case 226: + case 227: return -3; - case 172: - return 539110741; + case 175: + return 554784085; default: - return 536874325; + return 536892757; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -20210,7 +20937,10 @@ var ts; getAmbientModules: getAmbientModules, getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter + isOptionalParameter: isOptionalParameter, + tryFindAmbientModuleWithoutAugmentations: function (moduleName) { + return tryFindAmbientModule(moduleName, false); + } }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -20224,9 +20954,9 @@ var ts; var autoType = createIntrinsicType(1, "any"); var unknownType = createIntrinsicType(1, "unknown"); var undefinedType = createIntrinsicType(2048, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 524288, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 | 2097152, "undefined"); var nullType = createIntrinsicType(4096, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 524288, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 | 2097152, "null"); var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var trueType = createIntrinsicType(128, "true"); @@ -20236,11 +20966,15 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); + var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); + emptyTypeLiteralSymbol.members = ts.createMap(); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - anyFunctionType.flags |= 2097152; + anyFunctionType.flags |= 8388608; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); @@ -20328,6 +21062,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", @@ -20348,6 +21084,21 @@ var ts; builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); return checker; + function getJsxNamespace() { + if (_jsxNamespace === undefined) { + _jsxNamespace = "React"; + if (compilerOptions.jsxFactory) { + _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + if (_jsxFactoryEntity) { + _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text; + } + } + else if (compilerOptions.reactNamespace) { + _jsxNamespace = compilerOptions.reactNamespace; + } + } + return _jsxNamespace; + } function getEmitResolver(sourceFile, cancellationToken) { getDiagnostics(sourceFile, cancellationToken); return emitResolver; @@ -20428,7 +21179,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 && source.valueDeclaration.kind !== 226))) { + (target.valueDeclaration.kind === 229 && source.valueDeclaration.kind !== 229))) { target.valueDeclaration = source.valueDeclaration; } ts.forEach(source.declarations, function (node) { @@ -20484,7 +21235,7 @@ var ts; var moduleNotFoundError = !ts.isInAmbientContext(moduleName.parent.parent) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; - var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError); + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true); if (!mainModule) { return; } @@ -20525,7 +21276,7 @@ var ts; return type.flags & 32768 ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 256 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 260 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -20569,7 +21320,7 @@ var ts; return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - return declaration.kind !== 219 || + return declaration.kind !== 222 || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -20577,17 +21328,17 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201: - case 207: - case 209: + case 204: + case 210: + case 212: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 208: - case 209: + case 211: + case 212: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } @@ -20604,7 +21355,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 146 && + current.parent.kind === 147 && (ts.getModifierFlags(current.parent) & 32) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -20627,18 +21378,18 @@ var ts; if (result = getSymbol(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 793064 && lastLocation.kind !== 273) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 277) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 143 || - lastLocation.kind === 142 + lastLocation.kind === 144 || + lastLocation.kind === 143 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 143 || + lastLocation.kind === 144 || (lastLocation === location.type && - result.valueDeclaration.kind === 143); + result.valueDeclaration.kind === 144); } } if (useResult) { @@ -20650,13 +21401,13 @@ var ts; } } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226: + case 229: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 || ts.isAmbientModule(location)) { + if (location.kind === 260 || ts.isAmbientModule(location)) { if (result = moduleExports["default"]) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20666,7 +21417,7 @@ var ts; } if (moduleExports[name] && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 239)) { + ts.getDeclarationOfKind(moduleExports[name], 242)) { break; } } @@ -20674,13 +21425,13 @@ var ts; break loop; } break; - case 225: + case 228: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 147: case 146: - case 145: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20690,9 +21441,9 @@ var ts; } } break; - case 222: - case 193: - case 223: + case 225: + case 196: + case 226: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); @@ -20700,7 +21451,7 @@ var ts; } break loop; } - if (location.kind === 193 && meaning & 32) { + if (location.kind === 196 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20708,28 +21459,28 @@ var ts; } } break; - case 141: + case 142: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 223) { + if (ts.isClassLike(grandparent) || grandparent.kind === 226) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 148: - case 147: case 149: + case 148: case 150: case 151: - case 221: - case 181: + case 152: + case 224: + case 184: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180: + case 183: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20742,8 +21493,8 @@ var ts; } } break; - case 144: - if (location.parent && location.parent.kind === 143) { + case 145: + if (location.parent && location.parent.kind === 144) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20785,7 +21536,7 @@ var ts; } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 229) { + if (decls && decls.length === 1 && decls[0].kind === 232) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20832,9 +21583,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70: - case 173: + case 176: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195: + case 198: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20855,7 +21606,7 @@ var ts; ts.Debug.assert((result.flags & 2) !== 0); var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 222), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -20872,10 +21623,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230) { + if (node.kind === 233) { return node; } - while (node && node.kind !== 231) { + while (node && node.kind !== 234) { node = node.parent; } return node; @@ -20885,7 +21636,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 241) { + if (node.moduleReference.kind === 244) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -20946,28 +21697,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_16 = specifier.propertyName || specifier.name; - if (name_16.text) { + var name_19 = specifier.propertyName || specifier.name; + if (name_19.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_16.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_19.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_16.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_19.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_16.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_16.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_19.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_19.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_16, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_16)); + error(name_19, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_19)); } return symbol; } @@ -20989,19 +21740,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230: - return getTargetOfImportEqualsDeclaration(node); - case 232: - return getTargetOfImportClause(node); case 233: - return getTargetOfNamespaceImport(node); + return getTargetOfImportEqualsDeclaration(node); case 235: - return getTargetOfImportSpecifier(node); - case 239: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node); case 236: + return getTargetOfNamespaceImport(node); + case 238: + return getTargetOfImportSpecifier(node); + case 242: + return getTargetOfExportSpecifier(node); + case 239: return getTargetOfExportAssignment(node); - case 229: + case 232: return getTargetOfNamespaceExportDeclaration(node); } } @@ -21045,10 +21796,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236) { + if (node.kind === 239) { checkExpressionCached(node.expression); } - else if (node.kind === 239) { + else if (node.kind === 242) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21060,11 +21811,11 @@ var ts; if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 140) { + if (entityName.kind === 70 || entityName.parent.kind === 141) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 230); + ts.Debug.assert(entityName.parent.kind === 233); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21083,9 +21834,9 @@ var ts; return undefined; } } - else if (name.kind === 140 || name.kind === 173) { - var left = name.kind === 140 ? name.left : name.expression; - var right = name.kind === 140 ? name.right : name.name; + else if (name.kind === 141 || name.kind === 176) { + var left = name.kind === 141 ? name.left : name.expression; + var right = name.kind === 141 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -21110,27 +21861,28 @@ var ts; function resolveExternalModuleName(location, moduleReferenceExpression) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); } - function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } if (moduleReferenceExpression.kind !== 9) { return; } var moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral); + return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); } - function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode) { + function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } var moduleName = ts.escapeIdentifier(moduleReference); if (moduleName === undefined) { return; } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512); - if (symbol) { - return getMergedSymbol(symbol); - } + var ambientModule = tryFindAmbientModule(moduleName, true); + if (ambientModule) { + return ambientModule; } + var isRelative = ts.isExternalModuleNameRelative(moduleName); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); + var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { return getMergedSymbol(sourceFile.symbol); @@ -21146,14 +21898,30 @@ var ts; return getMergedSymbol(pattern.symbol); } } + if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (isForAugmentation) { + ts.Debug.assert(!!moduleNotFoundError); + var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; + error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + } + else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + } + return undefined; + } if (moduleNotFoundError) { - var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); - if (tsExtension) { - var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + if (resolutionDiagnostic) { + error(errorNode, resolutionDiagnostic, moduleName, resolvedModule.resolvedFileName); } else { - error(errorNode, moduleNotFoundError, moduleName); + var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } } return undefined; @@ -21268,7 +22036,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 149 && ts.nodeIsPresent(member.body)) { + if (member.kind === 150 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21339,11 +22107,11 @@ var ts; } } switch (location_1.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226: + case 229: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -21376,7 +22144,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21407,7 +22175,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21421,10 +22189,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 146: - case 148: - case 150: + case 147: + case 149: case 151: + case 152: continue; default: return false; @@ -21480,7 +22248,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 260 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -21514,11 +22282,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 159 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 160 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 140 || entityName.kind === 173 || - entityName.parent.kind === 230) { + else if (entityName.kind === 141 || entityName.kind === 176 || + entityName.parent.kind === 233) { meaning = 1920; } else { @@ -21610,10 +22378,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 165) { + while (node.kind === 166) { node = node.parent; } - if (node.kind === 224) { + if (node.kind === 227) { return getSymbolOfNode(node); } } @@ -21621,7 +22389,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 && + node.parent.kind === 230 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21635,10 +22403,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193: + case 196: return "(Anonymous class)"; - case 180: - case 181: + case 183: + case 184: return "(Anonymous function)"; } } @@ -21690,9 +22458,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -21744,9 +22512,7 @@ var ts; else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags); } - else if (!(flags & 512) && - (getObjectFlags(type) & 16 && !type.target || type.flags & 196608) && - type.aliasSymbol && + else if (!(flags & 512) && (getObjectFlags(type) & 16 || type.flags & 196608) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) { var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -21760,6 +22526,17 @@ var ts; else if (type.flags & 96) { writer.writeStringLiteral(literalTypeToString(type)); } + else if (type.flags & 262144) { + writer.writeKeyword("keyof"); + writeSpace(writer); + writeType(type.type, 64); + } + else if (type.flags & 524288) { + writeType(type.objectType, 64); + writePunctuation(writer, 20); + writeType(type.indexType, 0); + writePunctuation(writer, 21); + } else { writePunctuation(writer, 16); writeSpace(writer); @@ -21816,12 +22593,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -21855,7 +22632,7 @@ var ts; } else if (ts.contains(symbolStack, symbol)) { var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias && !type.target) { + if (typeAlias) { buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { @@ -21880,7 +22657,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 || declaration.parent.kind === 227; + return declaration.parent.kind === 260 || declaration.parent.kind === 230; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -21896,7 +22673,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } writePunctuation(writer, 20); @@ -21914,7 +22691,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129); + writeKeyword(writer, 130); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -21970,6 +22747,12 @@ var ts; writePunctuation(writer, 16); writer.writeLine(); writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, 17); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); @@ -21982,8 +22765,8 @@ var ts; writePunctuation(writer, 24); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 133); - writeIndexSignature(resolved.numberIndexInfo, 131); + writeIndexSignature(resolved.stringIndexInfo, 134); + writeIndexSignature(resolved.numberIndexInfo, 132); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -22006,9 +22789,6 @@ var ts; writer.writeLine(); } } - writer.decreaseIndent(); - writePunctuation(writer, 17); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -22046,12 +22826,12 @@ var ts; buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { writePunctuation(writer, 16); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { writePunctuation(writer, 20); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -22065,7 +22845,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170); + ts.Debug.assert(bindingElement.kind === 173); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55); @@ -22193,63 +22973,63 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170: + case 173: return isDeclarationVisible(node.parent.parent); - case 219: + case 222: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 226: - case 222: - case 223: - case 224: - case 221: + case 229: case 225: - case 230: + case 226: + case 227: + case 224: + case 228: + case 233: if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_9 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 230 && parent_10.kind !== 256 && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 233 && parent_9.kind !== 260 && ts.isInAmbientContext(parent_9))) { + return isGlobalSourceFile(parent_9); } - return isDeclarationVisible(parent_10); - case 146: - case 145: - case 150: - case 151: - case 148: + return isDeclarationVisible(parent_9); case 147: + case 146: + case 151: + case 152: + case 149: + case 148: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 149: - case 153: - case 152: + case 150: case 154: - case 143: - case 227: - case 157: + case 153: + case 155: + case 144: + case 230: case 158: - case 160: - case 156: + case 159: case 161: + case 157: case 162: case 163: case 164: case 165: + case 166: return isDeclarationVisible(node.parent); - case 232: - case 233: case 235: - return false; - case 142: - case 256: - case 229: - return true; case 236: + case 238: + return false; + case 143: + case 260: + case 232: + return true; + case 239: return false; default: return false; @@ -22258,10 +23038,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236) { + if (node.parent && node.parent.kind === 239) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 239) { + else if (node.parent.kind === 242) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22339,12 +23119,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219: - case 220: + case 222: + case 223: + case 238: + case 237: + case 236: case 235: - case 234: - case 233: - case 232: node = node.parent; break; default: @@ -22370,22 +23150,30 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70: - return name.text; - case 9: - case 8: - return name.text; - case 141: - if (ts.isStringOrNumericLiteral(name.expression.kind)) { - return name.expression.text; - } - } - return undefined; - } function isComputedNonLiteralName(name) { - return name.kind === 141 && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression.kind); + } + function getRestType(source, properties, symbol) { + ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + var members = ts.createMap(); + var names = ts.createMap(); + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var name_20 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_20)] = true; + } + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + var inNamesToRemove = prop.name in names; + var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16); + var isMethod = prop.flags & 8192; + var isSetOnlyAccessor = prop.flags & 65536 && !(prop.flags & 32768); + if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + members[prop.name] = prop; + } + } + var stringIndexInfo = getIndexInfoOfType(source, 0); + var numberIndexInfo = getIndexInfoOfType(source, 1); + return createAnonymousType(symbol, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } function getTypeForBindingElement(declaration) { var pattern = declaration.parent; @@ -22400,26 +23188,45 @@ var ts; return parentType; } var type; - if (pattern.kind === 168) { - var name_17 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_17)) { - return anyType; + if (pattern.kind === 171) { + if (declaration.dotDotDotToken) { + if (!(parentType.flags & 32768)) { + error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); + return unknownType; + } + var literalMembers = []; + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 197 && !element.dotDotDotToken) { + literalMembers.push(element.propertyName || element.name); + } + } + type = getRestType(parentType, literalMembers, declaration.symbol); } - if (declaration.initializer) { - getContextualType(declaration.initializer); - } - var text = getTextOfPropertyName(name_17); - type = getTypeOfPropertyOfType(parentType, text) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || - getIndexTypeOfType(parentType, 0); - if (!type) { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_17)); - return unknownType; + else { + var name_21 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_21)) { + return anyType; + } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } + var text = ts.getTextOfPropertyName(name_21); + type = getTypeOfPropertyOfType(parentType, text) || + isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || + getIndexTypeOfType(parentType, 0); + if (!type) { + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_21)); + return unknownType; + } } } else { var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); - if (!declaration.dotDotDotToken) { + if (declaration.dotDotDotToken) { + type = createArrayType(elementType); + } + else { var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) @@ -22434,9 +23241,6 @@ var ts; return unknownType; } } - else { - type = createArrayType(elementType); - } } if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 2048)) { type = getTypeWithFacts(type, 131072); @@ -22456,15 +23260,15 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 219 && - declaration.parent.kind === 220 && - declaration.parent.parent.kind === 201) { + if (declaration.kind === 222 && + declaration.parent.kind === 223 && + declaration.parent.parent.kind === 204) { var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 143) { + else if (declaration.kind === 144) { var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); if (paramTag && paramTag.typeExpression) { return paramTag.typeExpression.type; @@ -22478,22 +23282,22 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 && expr.elements.length === 0; + return expr.kind === 174 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.parent.parent.kind === 208) { + if (declaration.parent.parent.kind === 211) { return stringType; } - if (declaration.parent.parent.kind === 209) { + if (declaration.parent.parent.kind === 212) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -22502,7 +23306,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 219 && !ts.isBindingPattern(declaration.name) && + if (declaration.kind === 222 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22511,10 +23315,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var func = declaration.parent; - if (func.kind === 151 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150); + if (func.kind === 152 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22540,7 +23344,7 @@ var ts; var type = checkDeclarationInitializer(declaration); return addOptionality(type, declaration.questionToken && includeOptionality); } - if (declaration.kind === 254) { + if (declaration.kind === 257) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22565,11 +23369,11 @@ var ts; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { + if (isComputedNonLiteralName(name) || e.dotDotDotToken) { hasComputedProperties = true; return; } - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -22600,7 +23404,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 + return pattern.kind === 171 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22610,7 +23414,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 253) { + if (declaration.kind === 256) { return type; } return getWidenedType(type); @@ -22625,7 +23429,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 143 ? root.parent : root; + var memberDeclaration = root.kind === 144 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22638,25 +23442,25 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 236) { + if (declaration.kind === 239) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 && declaration.kind === 280 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 284 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 188 || - declaration.kind === 173 && declaration.parent.kind === 188) { - if (declaration.flags & 1048576) { + if (declaration.kind === 191 || + declaration.kind === 176 && declaration.parent.kind === 191) { + if (declaration.flags & 2097152) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 191 ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, true); @@ -22682,7 +23486,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150) { + if (accessor.kind === 151) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22702,9 +23506,9 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 150); - var setter = ts.getDeclarationOfKind(symbol, 151); - if (getter && getter.flags & 1048576) { + var getter = ts.getDeclarationOfKind(symbol, 151); + var setter = ts.getDeclarationOfKind(symbol, 152); + if (getter && getter.flags & 2097152) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -22744,7 +23548,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 150); + var getter_1 = ts.getDeclarationOfKind(symbol, 151); error(getter_1, 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)); } } @@ -22755,7 +23559,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 226 && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -22840,9 +23644,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 222 || node.kind === 193 || - node.kind === 221 || node.kind === 180 || - node.kind === 148 || node.kind === 181) { + if (node.kind === 225 || node.kind === 196 || + node.kind === 224 || node.kind === 183 || + node.kind === 149 || node.kind === 184) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -22851,15 +23655,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 223); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 226); return appendOuterTypeParameters(undefined, declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 223 || node.kind === 222 || - node.kind === 193 || node.kind === 224) { + if (node.kind === 226 || node.kind === 225 || + node.kind === 196 || node.kind === 227) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -22985,7 +23789,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 226 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -23014,7 +23818,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223) { + if (declaration.kind === 226) { if (declaration.flags & 64) { return false; } @@ -23065,7 +23869,7 @@ var ts; return unknownType; } var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279); + var declaration = ts.getDeclarationOfKind(symbol, 283); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -23076,7 +23880,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224); + declaration = ts.getDeclarationOfKind(symbol, 227); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -23100,14 +23904,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8 || expr.kind === 70 && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -23135,7 +23939,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225) { + if (declaration.kind === 228) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -23173,7 +23977,7 @@ var ts; if (!links.declaredType) { var type = createType(16384); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 142).constraint) { + if (!ts.getDeclarationOfKind(symbol, 143).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -23223,19 +24027,19 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 167: + case 129: + case 170: return true; - case 161: + case 162: return isIndependentType(node.elementType); - case 156: + case 157: return isIndependentTypeReference(node); } return false; @@ -23244,7 +24048,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 149 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 150 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -23260,12 +24064,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 146: - case 145: - return isIndependentVariableLikeDeclaration(declaration); - case 148: case 147: + case 146: + return isIndependentVariableLikeDeclaration(declaration); case 149: + case 148: + case 150: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23331,8 +24135,8 @@ var ts; else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); + constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } @@ -23394,7 +24198,7 @@ var ts; var baseSig = baseSignatures_1[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23487,6 +24291,9 @@ var ts; function intersectIndexInfos(info1, info2) { return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); } + function unionSpreadIndexInfos(info1, info2) { + return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { var callSignatures = emptyArray; var constructSignatures = emptyArray; @@ -23505,8 +24312,8 @@ var ts; var symbol = type.symbol; if (type.target) { var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); - var callSignatures = instantiateList(getSignaturesOfType(type.target, 0), type.mapper, instantiateSignature); - var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1), type.mapper, instantiateSignature); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper); var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper); var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -23607,7 +24414,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 196608 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } function getApparentTypeOfTypeParameter(type) { if (!type.resolvedApparentType) { @@ -23620,22 +24429,13 @@ var ts; return type.resolvedApparentType; } function getApparentType(type) { - if (type.flags & 16384) { - type = getApparentTypeOfTypeParameter(type); - } - if (type.flags & 34) { - type = globalStringType; - } - else if (type.flags & 340) { - type = globalNumberType; - } - else if (type.flags & 136) { - type = globalBooleanType; - } - else if (type.flags & 512) { - type = getGlobalESSymbolType(); - } - return type; + var t = type.flags & 16384 ? getApparentTypeOfTypeParameter(type) : type; + return t.flags & 34 ? globalStringType : + t.flags & 340 ? globalNumberType : + t.flags & 136 ? globalBooleanType : + t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 262144 ? stringOrNumberType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -23776,7 +24576,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -23804,8 +24604,8 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 1048576) { - if (node.type && node.type.kind === 268) { + if (node.flags & 2097152) { + if (node.type && node.type.kind === 272) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -23814,11 +24614,18 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268; + return paramTag.typeExpression.type.kind === 272; } } } } + function tryFindAmbientModule(moduleName, withAugmentations) { + if (ts.isExternalModuleNameRelative(moduleName)) { + return undefined; + } + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; + } function isOptionalParameter(node) { if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) { return true; @@ -23872,7 +24679,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167) { + if (param.type && param.type.kind === 170) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -23884,10 +24691,10 @@ var ts; minArgumentCount = -1; } } - if ((declaration.kind === 150 || declaration.kind === 151) && + if ((declaration.kind === 151 || declaration.kind === 152) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 150 ? 151 : 150; + var otherKind = declaration.kind === 151 ? 152 : 151; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -23899,14 +24706,14 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - var classType = declaration.kind === 149 ? + var classType = declaration.kind === 150 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 155 ? + var typePredicate = declaration.type && declaration.type.kind === 156 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -23923,14 +24730,14 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 1048576) { + if (declaration.flags & 2097152) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; } } - if (declaration.kind === 150 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 151); + if (declaration.kind === 151 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 152); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -23944,20 +24751,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 269: + case 152: + case 183: + case 184: + case 273: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -24025,6 +24832,11 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); + var id = getTypeListId(typeArguments); + return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + } + function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { @@ -24037,7 +24849,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 || signature.declaration.kind === 153; + var isConstructor = signature.declaration.kind === 150 || signature.declaration.kind === 154; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -24051,7 +24863,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 131 : 133; + var syntaxKind = kind === 1 ? 132 : 134; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -24078,7 +24890,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 142).constraint; + return ts.getDeclarationOfKind(type.symbol, 143).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -24111,7 +24923,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143).parent); } function getTypeListId(types) { var result = ""; @@ -24144,7 +24956,7 @@ var ts; result |= type.flags; } } - return result & 3670016; + return result & 14680064; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -24212,11 +25024,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156: + case 157: return node.typeName; - case 267: + case 271: return node.name; - case 195: + case 198: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -24240,7 +25052,7 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 267) { + if (symbol.flags & 107455 && node.kind === 271) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); @@ -24250,13 +25062,13 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267) { + if (node.kind === 271) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { - var typeNameOrExpression = node.kind === 156 + var typeNameOrExpression = node.kind === 157 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -24285,9 +25097,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 222: - case 223: case 225: + case 226: + case 228: return declaration; } } @@ -24425,7 +25237,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096) typeSet.containsNull = true; - if (!(flags & 524288)) + if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192)) { @@ -24501,7 +25313,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 && types.containsString || t.flags & 64 && types.containsNumber || - t.flags & 96 && t.flags & 262144 && containsType(types, t.regularType); + t.flags & 96 && t.flags & 1048576 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -24578,14 +25390,14 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var _loop_1 = function (i) { + var _loop_2 = function (i) { var type_1 = types[i]; if (type_1.flags & 65536) { return { value: getUnionType(ts.map(type_1.types, function (t) { return getIntersectionType(ts.replaceElement(types, i, t)); }), false, aliasSymbol, aliasTypeArguments) }; } }; for (var i = 0; i < types.length; i++) { - var state_2 = _loop_1(i); + var state_2 = _loop_2(i); if (typeof state_2 === "object") return state_2.value; } @@ -24615,25 +25427,215 @@ var ts; } return links.resolvedType; } + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return ts.startsWith(prop.name, "__@") ? neverType : getLiteralTypeForText(32, ts.unescapeIdentifier(prop.name)); + } + function getLiteralTypeFromPropertyNames(type) { + return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName)); + } + function getIndexType(type) { + return type.flags & 16384 ? getIndexTypeForTypeParameter(type) : + type.flags & 1 || getIndexInfoOfType(type, 0) ? stringOrNumberType : + getIndexInfoOfType(type, 1) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getLiteralTypeFromPropertyNames(type); + } + function getTypeFromTypeOperatorNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexType(getTypeFromTypeNodeNoAlias(node.type)); + } + return links.resolvedType; + } + function createIndexedAccessType(objectType, indexType) { + var type = createType(524288); + type.objectType = objectType; + type.indexType = indexType; + return type; + } + function getIndexedAccessTypeForTypeParameter(objectType, indexType) { + var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); + return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); + } + function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { + var accessExpression = accessNode && accessNode.kind === 177 ? accessNode : undefined; + var propName = indexType.flags & (32 | 64 | 256) ? + indexType.text : + accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? + ts.getPropertyNameForKnownSymbolName(accessExpression.argumentExpression.name.text) : + undefined; + if (propName) { + var prop = getPropertyOfType(objectType, propName); + if (prop) { + if (accessExpression) { + if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { + error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); + return unknownType; + } + if (cacheSymbol) { + getNodeLinks(accessNode).resolvedSymbol = prop; + } + } + return getTypeOfSymbol(prop); + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512)) { + if (isTypeAny(objectType)) { + return anyType; + } + var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340) && getIndexInfoOfType(objectType, 1) || + getIndexInfoOfType(objectType, 0) || + undefined; + if (indexInfo) { + if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + return unknownType; + } + return indexInfo.type; + } + if (accessExpression && !isConstEnumObjectType(objectType)) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (getIndexTypeOfType(objectType, 1)) { + error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } + } + return anyType; + } + } + if (accessNode) { + var indexNode = accessNode.kind === 177 ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (32 | 64)) { + error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); + } + else if (indexType.flags & (2 | 4)) { + error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); + } + else { + error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); + } + } + return unknownType; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + if (indexType.flags & 16384) { + if (!isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + if (accessNode) { + error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); + } + return unknownType; + } + return getIndexedAccessTypeForTypeParameter(objectType, indexType); + } + var apparentType = getApparentType(objectType); + if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + var propTypes = []; + for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, false); + if (propType === unknownType) { + return unknownType; + } + propTypes.push(propType); + } + return getUnionType(propTypes); + } + return getPropertyTypeForIndexType(apparentType, indexType, accessNode, true); + } + function getTypeFromIndexedAccessTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexedAccessType(getTypeFromTypeNodeNoAlias(node.objectType), getTypeFromTypeNodeNoAlias(node.indexType), node); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(16, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; - links.resolvedType = type; + if (ts.isEmpty(node.symbol.members) && !aliasSymbol && !aliasTypeArguments) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = type; + } } return links.resolvedType; } + function getSpreadType(left, right, isFromObjectLiteral) { + ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); + if (left.flags & 1 || right.flags & 1) { + return anyType; + } + var members = ts.createMap(); + var skippedPrivateMembers = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + if (left === emptyObjectType) { + stringIndexInfo = getIndexInfoOfType(right, 0); + numberIndexInfo = getIndexInfoOfType(right, 1); + } + else { + stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0)); + numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1)); + } + for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { + var rightProp = _a[_i]; + var isOwnProperty = !(rightProp.flags & 8192) || isFromObjectLiteral; + var isSetterWithoutGetter = rightProp.flags & 65536 && !(rightProp.flags & 32768); + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) { + skippedPrivateMembers[rightProp.name] = true; + } + else if (isOwnProperty && !isSetterWithoutGetter) { + members[rightProp.name] = rightProp; + } + } + for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { + var leftProp = _c[_b]; + if (leftProp.flags & 65536 && !(leftProp.flags & 32768) + || leftProp.name in skippedPrivateMembers) { + continue; + } + if (leftProp.name in members) { + var rightProp = members[leftProp.name]; + var rightType = getTypeOfSymbol(rightProp); + if (maybeTypeOfKind(rightType, 2048) || rightProp.flags & 536870912) { + var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); + var flags = 4 | 67108864 | (leftProp.flags & 536870912); + var result = createSymbol(flags, leftProp.name); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); + result.leftSpread = leftProp; + result.rightSpread = rightProp; + result.declarations = declarations; + result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); + members[leftProp.name] = result; + } + } + else { + members[leftProp.name] = leftProp; + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 && !(type.flags & 262144)) { + if (type.flags & 96 && !(type.flags & 1048576)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 262144, type.text); + var freshType = createLiteralType(type.flags | 1048576, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -24642,7 +25644,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 262144 ? type.regularType : type; + return type.flags & 96 && type.flags & 1048576 ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 ? stringLiteralTypes : numericLiteralTypes; @@ -24674,9 +25676,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 223)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 226)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 149 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 150 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -24696,79 +25698,83 @@ var ts; function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { case 118: - case 258: - case 259: + case 262: + case 263: return anyType; - case 133: + case 134: return stringType; - case 131: + case 132: return numberType; case 121: return booleanType; - case 134: + case 135: return esSymbolType; case 104: return voidType; - case 136: + case 137: return undefinedType; case 94: return nullType; - case 128: + case 129: return neverType; - case 283: + case 287: return nullType; - case 284: + case 288: return undefinedType; - case 285: + case 289: return neverType; - case 166: + case 167: case 98: return getTypeFromThisTypeNode(node); - case 167: + case 170: return getTypeFromLiteralTypeNode(node); - case 282: + case 286: return getTypeFromLiteralTypeNode(node.literal); - case 156: - case 267: - return getTypeFromTypeReference(node); - case 155: - return booleanType; - case 195: - return getTypeFromTypeReference(node); - case 159: - return getTypeFromTypeQueryNode(node); - case 161: - case 260: - return getTypeFromArrayTypeNode(node); - case 162: - return getTypeFromTupleTypeNode(node); - case 163: - case 261: - return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164: - return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 165: - case 263: - case 264: - case 271: - case 272: - case 268: - return getTypeFromTypeNode(node.type); - case 265: - return getTypeFromTypeNode(node.literal); case 157: - case 158: + case 271: + return getTypeFromTypeReference(node); + case 156: + return booleanType; + case 198: + return getTypeFromTypeReference(node); case 160: - case 281: + return getTypeFromTypeQueryNode(node); + case 162: + case 264: + return getTypeFromArrayTypeNode(node); + case 163: + return getTypeFromTupleTypeNode(node); + case 164: + case 265: + return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 165: + return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); + case 166: + case 267: + case 268: + case 275: + case 276: + case 272: + return getTypeFromTypeNode(node.type); case 269: + return getTypeFromTypeNode(node.literal); + case 158: + case 159: + case 161: + case 285: + case 273: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 168: + return getTypeFromTypeOperatorNode(node); + case 169: + return getTypeFromIndexedAccessTypeNode(node); case 70: - case 140: + case 141: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262: + case 266: return getTypeFromJSDocTupleType(node); - case 270: + case 274: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -24785,6 +25791,12 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -24807,7 +25819,6 @@ var ts; count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; - mapper.targetTypes = targets; return mapper; } function createTypeEraser(sources) { @@ -24910,32 +25921,35 @@ var ts; result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); mapper.instantiations[type.id] = result; return result; } function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { + if (!(symbol.declarations && symbol.declarations.length)) { + return false; + } var mappedTypes = mapper.mappedTypes; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 157: case 158: - case 221: - case 148: - case 147: + case 159: + case 224: case 149: - case 152: + case 148: + case 150: case 153: case 154: - case 150: + case 155: case 151: - case 180: - case 181: - case 222: - case 193: - case 223: - case 224: + case 152: + case 183: + case 184: + case 225: + case 196: + case 226: + case 227: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -24945,15 +25959,15 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223) { + if (ts.isClassLike(node) || node.kind === 226) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226: - case 256: + case 229: + case 260: return false; } node = node.parent; @@ -24973,14 +25987,20 @@ var ts; instantiateAnonymousType(type, mapper) : type; } if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), false, type.aliasSymbol, mapper.targetTypes); + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (type.flags & 131072) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } } return type; @@ -24989,27 +26009,27 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 180: - case 181: + case 183: + case 184: return isContextSensitiveFunctionLikeDeclaration(node); - case 172: + case 175: return ts.forEach(node.properties, isContextSensitive); - case 171: + case 174: return ts.forEach(node.elements, isContextSensitive); - case 189: + case 192: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188: + case 191: return node.operatorToken.kind === 53 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253: + case 256: return isContextSensitive(node.initializer); + case 149: case 148: - case 147: return isContextSensitiveFunctionLikeDeclaration(node); - case 179: + case 182: return isContextSensitive(node.expression); } return false; @@ -25021,7 +26041,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 181) { + if (node.kind === 184) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -25270,10 +26290,10 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { @@ -25286,7 +26306,7 @@ var ts; return related === 1; } } - if (source.flags & 245760 || target.flags & 245760) { + if (source.flags & 507904 || target.flags & 507904) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -25323,9 +26343,15 @@ var ts; targetType = typeToString(target, undefined, 128); } if (!message) { - message = relation === comparableRelation ? - ts.Diagnostics.Type_0_is_not_comparable_to_type_1 : - ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + if (relation === comparableRelation) { + message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1; + } + else if (sourceType === targetType) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; + } + else { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + } } reportError(message, sourceType, targetType); } @@ -25341,10 +26367,10 @@ var ts; } function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 && source.flags & 262144) { + if (source.flags & 96 && source.flags & 1048576) { source = source.regularType; } - if (target.flags & 96 && target.flags & 262144) { + if (target.flags & 96 && target.flags & 1048576) { target = target.regularType; } if (source === target) @@ -25354,7 +26380,7 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (getObjectFlags(source) & 64 && source.flags & 262144) { + if (getObjectFlags(source) & 64 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -25392,6 +26418,22 @@ var ts; return result; } } + if (target.flags & 16384) { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + } + } + else if (target.flags & 262144) { + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } if (source.flags & 16384) { var constraint = getConstraintOfTypeParameter(source); if (!constraint || constraint.flags & 1) { @@ -25656,8 +26698,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 64); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var targetProp = properties_3[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -26094,8 +27136,8 @@ var ts; type; } function getWidenedLiteralType(type) { - return type.flags & 32 && type.flags & 262144 ? stringType : - type.flags & 64 && type.flags & 262144 ? numberType : + return type.flags & 32 && type.flags & 1048576 ? stringType : + type.flags & 64 && type.flags & 1048576 ? numberType : type.flags & 128 ? booleanType : type.flags & 256 ? type.baseType : type.flags & 65536 && !(type.flags & 16) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : @@ -26174,7 +27216,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(getObjectFlags(type) & 64 && type.flags & 262144)) { + if (!(getObjectFlags(type) & 64 && type.flags & 1048576)) { return type; } var regularType = type.regularType; @@ -26184,7 +27226,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~262144; + regularNew.flags = resolved.flags & ~1048576; regularNew.objectFlags |= 64; type.regularType = regularNew; return regularNew; @@ -26202,7 +27244,7 @@ var ts; return type.flags & 6144 ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 1572864) { + if (type.flags & 6291456) { if (type.flags & 6144) { return anyType; } @@ -26240,7 +27282,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 524288) { + if (t.flags & 2097152) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -26254,25 +27296,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 147: case 146: - case 145: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 143: + case 144: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 170: + case 173: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221: + case 224: + case 149: case 148: - case 147: - case 150: case 151: - case 180: - case 181: + case 152: + case 183: + case 184: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -26285,7 +27327,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -26392,7 +27434,7 @@ var ts; } } if (target.flags & 16384) { - if (source.flags & 2097152) { + if (source.flags & 8388608) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -26479,8 +27521,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -26554,7 +27596,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 8190); + return constraint && maybeTypeOfKind(constraint, 8190 | 262144); } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; @@ -26607,10 +27649,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 159: + case 160: return true; case 70: - case 140: + case 141: node = node.parent; continue; default: @@ -26627,7 +27669,7 @@ var ts; if (node.kind === 98) { return "0"; } - if (node.kind === 173) { + if (node.kind === 176) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -26638,7 +27680,7 @@ var ts; case 70: case 98: return node; - case 173: + case 176: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -26647,19 +27689,19 @@ var ts; switch (source.kind) { case 70: return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 || target.kind === 170) && + (target.kind === 222 || target.kind === 173) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98: return target.kind === 98; - case 173: - return target.kind === 173 && + case 176: + return target.kind === 176 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173) { + while (source.kind === 176) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -26668,7 +27710,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 && + return target.kind === 176 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -26676,7 +27718,7 @@ var ts; if (expr.kind === 70) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173) { + if (expr.kind === 176) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -26706,7 +27748,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 && + if (callExpression.expression.kind === 176 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -26817,7 +27859,7 @@ var ts; return type; } function getTypeOfDestructuredProperty(type, name) { - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || @@ -26828,19 +27870,19 @@ var ts; checkIteratedTypeOrElementType(type, undefined, false) || unknownType; } - function getTypeOfDestructuredSpreadElement(type) { + function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 171 || node.parent.kind === 253 ? + return node.parent.kind === 174 || node.parent.kind === 256 ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } - function getAssignedTypeOfSpreadElement(node) { - return getTypeOfDestructuredSpreadElement(getAssignedType(node.parent)); + function getAssignedTypeOfSpreadExpression(node) { + return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent)); } function getAssignedTypeOfPropertyAssignment(node) { return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name); @@ -26851,21 +27893,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208: + case 211: return stringType; - case 209: + case 212: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188: + case 191: return getAssignedTypeOfBinaryExpression(parent); - case 182: + case 185: return undefinedType; - case 171: + case 174: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192: - return getAssignedTypeOfSpreadElement(parent); - case 253: + case 195: + return getAssignedTypeOfSpreadExpression(parent); + case 256: return getAssignedTypeOfPropertyAssignment(parent); - case 254: + case 257: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -26873,11 +27915,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 ? + var type = pattern.kind === 171 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : - getTypeOfDestructuredSpreadElement(parentType); + getTypeOfDestructuredSpreadExpression(parentType); return getTypeWithDefault(type, node.initializer); } function getTypeOfInitializer(node) { @@ -26888,35 +27930,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208) { + if (node.parent.parent.kind === 211) { return stringType; } - if (node.parent.parent.kind === 209) { + if (node.parent.parent.kind === 212) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 ? + return node.kind === 222 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 || node.kind === 170 ? + return node.kind === 222 || node.kind === 173 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 && node.initializer && + return node.kind === 222 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 && node.parent.kind === 188 && + node.kind !== 173 && node.parent.kind === 191 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179: + case 182: return getReferenceCandidate(node.expression); - case 188: + case 191: switch (node.operatorToken.kind) { case 57: return getReferenceCandidate(node.left); @@ -26928,13 +27970,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 179 || - parent.kind === 188 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 188 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 182 || + parent.kind === 191 && parent.operatorToken.kind === 57 && parent.left === node || + parent.kind === 191 && parent.operatorToken.kind === 25 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249) { + if (clause.kind === 252) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -27052,11 +28094,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 173 && (parent.name.text === "length" || - parent.parent.kind === 175 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 174 && + var isLengthPushOrUnshift = parent.kind === 176 && (parent.name.text === "length" || + parent.parent.kind === 178 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 177 && parent.expression === root && - parent.parent.kind === 188 && + parent.parent.kind === 191 && parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -27065,7 +28107,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 246783)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -27075,7 +28117,7 @@ var ts; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 128 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 200 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -27120,7 +28162,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 173) { + if (container && container !== flowContainer && reference.kind !== 176) { flow = container.flowNode; continue; } @@ -27140,7 +28182,7 @@ var ts; function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { - if (node.parent.kind === 186 || node.parent.kind === 187) { + if (ts.getAssignmentTargetKind(node) === 2) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -27163,7 +28205,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 ? + var expr = node.kind === 178 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -27171,7 +28213,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 128) { var evolvedType_1 = type; - if (node.kind === 175) { + if (node.kind === 178) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -27289,7 +28331,7 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 && + return expr.kind === 176 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -27323,10 +28365,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 === 183 && right_1.kind === 9) { + if (left_1.kind === 186 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 183 && left_1.kind === 9) { + if (right_1.kind === 186 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -27503,10 +28545,10 @@ var ts; } } else { - var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 174 || invokedExpression.kind === 173) { + var invokedExpression = ts.skipParentheses(callExpression.expression); + if (invokedExpression.kind === 177 || invokedExpression.kind === 176) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -27521,15 +28563,15 @@ var ts; switch (expr.kind) { case 70: case 98: - case 173: + case 176: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175: + case 178: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179: + case 182: return narrowType(type, expr.expression, assumeTrue); - case 188: + case 191: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186: + case 189: if (expr.operator === 50) { return narrowType(type, expr.operand, !assumeTrue); } @@ -27552,19 +28594,13 @@ var ts; } return getTypeOfSymbol(symbol); } - function skipParenthesizedNodes(expression) { - while (expression.kind === 179) { - expression = expression.expression; - } - return expression; - } function getControlFlowContainer(node) { while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 227 || - node.kind === 256 || - node.kind === 146) { + node.kind === 230 || + node.kind === 260 || + node.kind === 147) { return node; } } @@ -27595,7 +28631,7 @@ var ts; if (node.kind === 70) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144) { symbol.isAssigned = true; } } @@ -27609,19 +28645,23 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return unknownType; + } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 181) { + if (container.kind === 184) { 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.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 262144) { + if (node.flags & 524288) { getNodeLinks(container).flags |= 8192; } + return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -27630,7 +28670,7 @@ var ts; if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; if (languageVersion === 2 - && declaration_1.kind === 222 + && declaration_1.kind === 225 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -27642,11 +28682,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193) { + else if (declaration_1.kind === 196) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 146 && ts.hasModifier(container, 32)) { + if (container.kind === 147 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -27661,15 +28701,26 @@ var ts; checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; - if (!(localOrExportSymbol.flags & 3) || ts.isAssignmentTarget(node) || !declaration) { + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (!(localOrExportSymbol.flags & 3)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + return unknownType; + } + if (isReadonlySymbol(localOrExportSymbol)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); + return unknownType; + } + } + if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 143; + var isParameter = ts.getRootDeclaration(declaration).kind === 144; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 180 || - flowContainer.kind === 181 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 183 || + flowContainer.kind === 184 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -27690,7 +28741,7 @@ var ts; error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } - return flowType; + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { var current = node; @@ -27705,7 +28756,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 252) { + symbol.valueDeclaration.parent.kind === 255) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -27723,8 +28774,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 207 && - ts.getAncestor(symbol.valueDeclaration, 220).parent === container && + if (container.kind === 210 && + ts.getAncestor(symbol.valueDeclaration, 223).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -27736,14 +28787,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 179) { + while (current.parent.kind === 182) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 186 || current.parent.kind === 187)) { + else if ((current.parent.kind === 189 || current.parent.kind === 190)) { var expr = current.parent; isAssigned = expr.operator === 42 || expr.operator === 43; } @@ -27762,7 +28813,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 146 || container.kind === 149) { + if (container.kind === 147 || container.kind === 150) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -27796,7 +28847,7 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 149) { + if (container.kind === 150) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) { @@ -27806,29 +28857,29 @@ var ts; } } } - if (container.kind === 181) { + if (container.kind === 184) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 226: + case 229: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 225: + case 228: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 149: + case 150: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 147: case 146: - case 145: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 141: + case 142: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -27837,7 +28888,7 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 180 && + if (container.kind === 183 && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent @@ -27872,27 +28923,27 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 269) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 273) { var jsDocFunctionType = typeTag.typeExpression.type; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 272) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 276) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 143) { + if (n.kind === 144) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 175 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 178 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 181) { + while (container && container.kind === 184) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -27901,16 +28952,16 @@ var ts; var nodeCheckFlag = 0; if (!canUseSuperExpression) { var current = node; - while (current && current !== container && current.kind !== 141) { + while (current && current !== container && current.kind !== 142) { current = current.parent; } - if (current && current.kind === 141) { + if (current && current.kind === 142) { 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 === 172)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 175)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -27925,7 +28976,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 148 && ts.getModifierFlags(container) & 256) { + if (container.kind === 149 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -27936,7 +28987,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172) { + if (container.parent.kind === 175) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -27954,7 +29005,7 @@ var ts; } return unknownType; } - if (container.kind === 149 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 150 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -27966,24 +29017,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 149; + return container.kind === 150; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 172) { + if (ts.isClassLike(container.parent) || container.parent.kind === 175) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || - container.kind === 151; + return container.kind === 149 || + container.kind === 148 || + container.kind === 151 || + container.kind === 152; } else { - return container.kind === 148 || - container.kind === 147 || - container.kind === 150 || + return container.kind === 149 || + container.kind === 148 || container.kind === 151 || + container.kind === 152 || + container.kind === 147 || container.kind === 146 || - container.kind === 145 || - container.kind === 149; + container.kind === 150; } } } @@ -27991,7 +29042,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 184) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -28047,7 +29098,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 143) { + if (declaration.kind === 144) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -28058,11 +29109,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_18 = declaration.propertyName || declaration.name; + var name_22 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_18)) { - var text = getTextOfPropertyName(name_18); + !ts.isBindingPattern(name_22)) { + var text = ts.getTextOfPropertyName(name_22); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -28099,7 +29150,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 143 && node.parent.initializer === node) { + if (node.parent.kind === 144 && node.parent.initializer === node) { return true; } node = node.parent; @@ -28108,8 +29159,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 149 || - functionDecl.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151))) { + functionDecl.kind === 150 || + functionDecl.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -28128,7 +29179,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177) { + if (template.parent.kind === 180) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -28236,13 +29287,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246) { + if (attribute.kind === 249) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247) { + else if (attribute.kind === 250) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -28260,41 +29311,41 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219: - case 143: + case 222: + case 144: + case 147: case 146: - case 145: - case 170: + case 173: return getContextualTypeForInitializerExpression(node); - case 181: - case 212: + case 184: + case 215: return getContextualTypeForReturnExpression(node); - case 191: + case 194: return getContextualTypeForYieldOperand(parent); - case 175: - case 176: - return getContextualTypeForArgument(parent, node); case 178: - case 196: - return getTypeFromTypeNode(parent.type); - case 188: - return getContextualTypeForBinaryOperand(node); - case 253: - case 254: - return getContextualTypeForObjectLiteralElement(parent); - case 171: - return getContextualTypeForElementExpression(node); - case 189: - return getContextualTypeForConditionalOperand(node); - case 198: - ts.Debug.assert(parent.parent.kind === 190); - return getContextualTypeForSubstitutionExpression(parent.parent, node); case 179: + return getContextualTypeForArgument(parent, node); + case 181: + case 199: + return getTypeFromTypeNode(parent.type); + case 191: + return getContextualTypeForBinaryOperand(node); + case 256: + case 257: + return getContextualTypeForObjectLiteralElement(parent); + case 174: + return getContextualTypeForElementExpression(node); + case 192: + return getContextualTypeForConditionalOperand(node); + case 201: + ts.Debug.assert(parent.parent.kind === 193); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 182: return getContextualType(parent); - case 248: + case 251: return getContextualType(parent); - case 246: - case 247: + case 249: + case 250: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -28323,7 +29374,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 || node.kind === 181; + return node.kind === 183 || node.kind === 184; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -28336,7 +29387,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -28372,13 +29423,13 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper.context; } - function checkSpreadElementExpression(node, contextualMapper) { + function checkSpreadExpression(node, contextualMapper) { var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper); return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); } function hasDefaultValue(node) { - return (node.kind === 170 && !!node.initializer) || - (node.kind === 188 && node.operatorToken.kind === 57); + return (node.kind === 173 && !!node.initializer) || + (node.kind === 191 && node.operatorToken.kind === 57); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -28387,7 +29438,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 192) { + if (inDestructuringPattern && e.kind === 195) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -28399,7 +29450,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192; + hasSpreadElement = hasSpreadElement || e.kind === 195; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -28410,7 +29461,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 169 || pattern.kind === 171)) { + if (pattern && (pattern.kind === 172 || pattern.kind === 174)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -28418,7 +29469,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194) { + if (patternElement.kind !== 197) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -28435,7 +29486,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 141 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 142 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -28477,9 +29528,11 @@ var ts; checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); var propertiesArray = []; + var spread = emptyObjectType; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 168 || contextualType.pattern.kind === 172); + (contextualType.pattern.kind === 171 || contextualType.pattern.kind === 175); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -28487,25 +29540,25 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 253 || - memberDecl.kind === 254 || + if (memberDecl.kind === 256 || + memberDecl.kind === 257 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253) { + if (memberDecl.kind === 256) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 148) { + else if (memberDecl.kind === 149) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 254); + ts.Debug.assert(memberDecl.kind === 257); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; var prop = createSymbol(4 | 67108864 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 253 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 254 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 256 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 257 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912; } @@ -28531,8 +29584,25 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 258) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + propertiesArray = []; + propertiesTable = ts.createMap(); + hasComputedStringProperty = false; + hasComputedNumberProperty = false; + typeFlags = 0; + } + var type = checkExpression(memberDecl.expression); + if (!(type.flags & (32768 | 1))) { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return unknownType; + } + spread = getSpreadType(spread, type, false); + continue; + } else { - ts.Debug.assert(memberDecl.kind === 150 || memberDecl.kind === 151); + ts.Debug.assert(memberDecl.kind === 151 || memberDecl.kind === 152); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -28560,19 +29630,33 @@ var ts; } } } - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 262144; - result.flags |= 1048576 | freshObjectLiteralFlag | (typeFlags & 3670016); - result.objectFlags |= 64; - if (patternWithComputedProperties) { - result.objectFlags |= 256; + if (spread !== emptyObjectType) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), true); + } + spread.flags |= propagatedFlags; + spread.symbol = node.symbol; + return spread; } - if (inDestructuringPattern) { - result.pattern = node; + return createObjectLiteralType(); + function createObjectLiteralType() { + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; + result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); + result.objectFlags |= 64; + if (patternWithComputedProperties) { + result.objectFlags |= 256; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144)) { + propagatedFlags |= (result.flags & 14680064); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -28589,13 +29673,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248: + case 251: checkJsxExpression(child); break; - case 242: + case 245: checkJsxElement(child); break; - case 243: + case 246: checkJsxSelfClosingElement(child); break; } @@ -28606,7 +29690,7 @@ var ts; return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 173 || tagName.kind === 98) { + if (tagName.kind === 176 || tagName.kind === 98) { return false; } else { @@ -28622,7 +29706,7 @@ var ts; var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); + var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0); if (attributeType) { correspondingPropType = attributeType; } @@ -28875,7 +29959,7 @@ var ts; checkGrammarJsxElement(node); checkJsxPreconditions(node); var reactRefErr = compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; + var reactNamespace = getJsxNamespace(); var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); if (reactSym) { reactSym.isReferenced = true; @@ -28887,11 +29971,11 @@ var ts; var nameTable = ts.createMap(); var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 246) { + if (node.attributes[i].kind === 249) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247); + ts.Debug.assert(node.attributes[i].kind === 250); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -28917,7 +30001,7 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 146; + return s.valueDeclaration ? s.valueDeclaration.kind : 147; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 ? 4 | 32 : 0; @@ -28928,11 +30012,11 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 173 || node.kind === 219 ? + var errorNode = node.kind === 176 || node.kind === 222 ? node.name : node.right; if (left.kind === 96) { - if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 148) { + if (languageVersion < 2 && getDeclarationKindFromSymbol(prop) !== 149) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -28995,6 +30079,33 @@ var ts; function checkQualifiedName(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } + function reportNonexistentProperty(propNode, containingType) { + var errorInfo; + if (containingType.flags & 65536 && !(containingType.flags & 8190)) { + for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { + var subtype = _a[_i]; + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + function markPropertyAsReferenced(prop) { + if (prop && + noUnusedIdentifiers && + (prop.flags & 106500) && + prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { + if (prop.flags & 16777216) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -29011,44 +30122,29 @@ var ts; } return unknownType; } - if (noUnusedIdentifiers && - (prop.flags & 106500) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8)) { - if (prop.flags & 16777216) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } + markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); - if (node.kind !== 173 || ts.isAssignmentTarget(node) || + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { + error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text); + return unknownType; + } + } + if (node.kind !== 176 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - return getFlowTypeOfReference(node, propType, true, undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 65536 && !(containingType.flags & 8190)) { - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } + var flowType = getFlowTypeOfReference(node, propType, true, undefined); + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 173 + var left = node.kind === 176 ? node.expression : node.left; var type = checkExpression(left); @@ -29062,7 +30158,7 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220) { + if (initializer.kind === 223) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -29077,14 +30173,14 @@ var ts; return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0); } function isForInVariableForNumericPropertyNames(expr) { - var e = skipParenthesizedNodes(expr); + var e = ts.skipParentheses(expr); if (e.kind === 70) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 208 && + if (node.kind === 211 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -29098,9 +30194,11 @@ var ts; return false; } function checkIndexedAccess(node) { - if (!node.argumentExpression) { + var objectType = checkNonNullExpression(node.expression); + var indexExpression = node.argumentExpression; + if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 176 && node.parent.expression === node) { + if (node.parent.kind === 179 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -29110,71 +30208,17 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } + return unknownType; } - var objectType = getApparentType(checkNonNullExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); if (objectType === unknownType || objectType === silentNeverType) { return objectType; } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { + error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - if (node.argumentExpression) { - var name_19 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_19 !== undefined) { - var prop = getPropertyOfType(objectType, name_19); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_19, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - var allowedNullableFlags = strictNullChecks ? 0 : 6144; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512 | allowedNullableFlags)) { - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexInfo = getIndexInfoOfType(objectType, 1); - if (numberIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; - return numberIndexInfo.type; - } - } - var stringIndexInfo = getIndexInfoOfType(objectType, 0); - if (stringIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; - return stringIndexInfo.type; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, getIndexTypeOfType(objectType, 1) ? - ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number : - ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; - } - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 || indexArgumentExpression.kind === 8) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 174 || indexArgumentExpression.kind === 173) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; + return getIndexedAccessType(objectType, indexType, node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { @@ -29207,10 +30251,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177) { + if (node.kind === 180) { checkExpression(node.template); } - else if (node.kind !== 144) { + else if (node.kind !== 145) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -29232,19 +30276,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_11 = signature.declaration && signature.declaration.parent; + var parent_10 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_10 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_10; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_10; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -29261,7 +30305,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 192) { + if (arg && arg.kind === 195) { return i; } } @@ -29274,11 +30318,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177) { + if (node.kind === 180) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190) { + if (tagExpression.template.kind === 193) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -29290,7 +30334,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 144) { + else if (node.kind === 145) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -29298,7 +30342,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 176); + ts.Debug.assert(callExpression.kind === 179); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -29357,7 +30401,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29404,7 +30448,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 176) { + if (thisType && thisType !== voidType && node.kind !== 179) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -29417,7 +30461,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 194) { + if (arg === undefined || arg.kind !== 197) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -29432,28 +30476,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 175) { + if (node.kind === 178) { var callee = node.expression; - if (callee.kind === 173) { + if (callee.kind === 176) { return callee.expression; } - else if (callee.kind === 174) { + else if (callee.kind === 177) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 177) { + if (node.kind === 180) { var template = node.template; args = [undefined]; - if (template.kind === 190) { + if (template.kind === 193) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144) { + else if (node.kind === 145) { return undefined; } else { @@ -29462,21 +30506,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 144) { + if (node.kind === 145) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return 1; - case 146: + case 147: return 2; - case 148: - case 150: + case 149: case 151: + case 152: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 143: + case 144: return 3; } } @@ -29485,48 +30529,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { node = node.parent; - if (node.kind === 149) { + if (node.kind === 150) { return anyType; } } - if (node.kind === 146 || - node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 147 || + node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var element = node; switch (element.name.kind) { case 70: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 141: + case 142: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -29543,20 +30587,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 222) { + if (node.kind === 225) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143) { + if (node.kind === 144) { return numberType; } - if (node.kind === 146) { + if (node.kind === 147) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 151) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 152) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -29577,26 +30621,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 144) { + if (node.kind === 145) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 144 || - (argIndex === 0 && node.kind === 177)) { + if (node.kind === 145 || + (argIndex === 0 && node.kind === 180)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 144) { + if (node.kind === 145) { return node.expression; } - else if (argIndex === 0 && node.kind === 177) { + else if (argIndex === 0 && node.kind === 180) { return node.template; } else { @@ -29604,8 +30648,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177; - var isDecorator = node.kind === 144; + var isTaggedTemplate = node.kind === 180; + var isDecorator = node.kind === 145; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -29635,7 +30679,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 175 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 178 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -29903,16 +30947,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222: - case 193: + case 225: + case 196: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 143: + case 144: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 146: + case 147: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 148: - case 150: + case 149: case 151: + case 152: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -29939,13 +30983,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175: + case 178: return resolveCallExpression(node, candidatesOutArray); - case 176: + case 179: return resolveNewExpression(node, candidatesOutArray); - case 177: + case 180: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144: + case 145: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -29977,12 +31021,12 @@ var ts; if (node.expression.kind === 96) { return voidType; } - if (node.kind === 176) { + if (node.kind === 179) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 149 && - declaration.kind !== 153 && - declaration.kind !== 158 && + declaration.kind !== 150 && + declaration.kind !== 154 && + declaration.kind !== 159 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = node.expression.kind === 70 ? getResolvedSymbol(node.expression) : @@ -30013,9 +31057,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 221 + ? 224 : resolvedRequire.flags & 3 - ? 219 + ? 222 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -30108,8 +31152,8 @@ var ts; if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 168 || - parameter.valueDeclaration.name.kind === 169)) { + (parameter.valueDeclaration.name.kind === 171 || + parameter.valueDeclaration.name.kind === 172)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -30136,7 +31180,7 @@ var ts; function createPromiseReturnType(func, promisedType) { var promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } return promiseType; @@ -30148,7 +31192,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200) { + if (func.body.kind !== 203) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); @@ -30227,7 +31271,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 217 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -30256,7 +31300,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 || func.kind === 181)) { + func.kind === 183 || func.kind === 184)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -30273,7 +31317,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 200 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 203 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -30300,9 +31344,9 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 180) { + if (!hasGrammarError && node.kind === 183) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { @@ -30336,14 +31380,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 148) { + if (produceDiagnostics && node.kind !== 149) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 148 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -30353,7 +31397,7 @@ var ts; if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200) { + if (node.body.kind === 203) { checkSourceElement(node.body); } else { @@ -30388,10 +31432,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 173 || expr.kind === 174) && + (expr.kind === 176 || expr.kind === 177) && expr.expression.kind === 98) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 149)) + if (!(func && func.kind === 150)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -30400,44 +31444,24 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 || expr.kind === 174) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 176 || expr.kind === 177) { + var node = ts.skipParentheses(expr.expression); if (node.kind === 70) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 233; + return declaration && declaration.kind === 236; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { - var node = skipParenthesizedNodes(expr); - if (node.kind !== 70 && node.kind !== 173 && node.kind !== 174) { + function checkReferenceExpression(expr, invalidReferenceMessage) { + var node = ts.skipParentheses(expr); + if (node.kind !== 70 && node.kind !== 176 && node.kind !== 177) { error(expr, invalidReferenceMessage); return false; } - var links = getNodeLinks(node); - var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - if (node.kind === 70 && !(symbol.flags & 3)) { - error(expr, invalidReferenceMessage); - return false; - } - if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { - error(expr, constantVariableMessage); - return false; - } - } - } - else if (node.kind === 174) { - if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { - error(expr, constantVariableMessage); - return false; - } - } return true; } function checkDeleteExpression(node) { @@ -30454,7 +31478,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 262144)) { + if (!(node.flags & 524288)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -30489,7 +31513,7 @@ var ts; case 43: var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -30502,7 +31526,7 @@ var ts; } var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -30578,29 +31602,29 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var p = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var p = properties_5[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { - if (property.kind === 253 || property.kind === 254) { - var name_20 = property.name; - if (name_20.kind === 141) { - checkComputedPropertyName(name_20); + if (property.kind === 256 || property.kind === 257) { + var name_23 = property.name; + if (name_23.kind === 142) { + checkComputedPropertyName(name_23); } - if (isComputedNonLiteralName(name_20)) { + if (isComputedNonLiteralName(name_23)) { return undefined; } - var text = getTextOfPropertyName(name_20); + var text = ts.getTextOfPropertyName(name_23); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 254) { + if (property.kind === 257) { return checkDestructuringAssignment(property, type); } else { @@ -30608,10 +31632,10 @@ var ts; } } else { - error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_20)); + error(name_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); } } - else { + else if (property.kind !== 258) { error(property, ts.Diagnostics.Property_assignment_expected); } } @@ -30626,8 +31650,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 194) { - if (element.kind !== 192) { + if (element.kind !== 197) { + if (element.kind !== 195) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -30649,11 +31673,11 @@ var ts; } else { if (elementIndex < elements.length - 1) { - error(element, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { var restExpression = element.expression; - if (restExpression.kind === 188 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 191 && restExpression.operatorToken.kind === 57) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -30666,7 +31690,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254) { + if (exprOrAssignment.kind === 257) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -30680,21 +31704,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 && target.operatorToken.kind === 57) { + if (target.kind === 191 && target.operatorToken.kind === 57) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172) { + if (target.kind === 175) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171) { + if (target.kind === 174) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { + if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -30705,35 +31729,35 @@ var ts; case 70: case 9: case 11: - case 177: - case 190: + case 180: + case 193: case 12: case 8: case 100: case 85: case 94: - case 136: - case 180: - case 193: - case 181: - case 171: - case 172: + case 137: case 183: - case 197: - case 243: - case 242: + case 196: + case 184: + case 174: + case 175: + case 186: + case 200: + case 246: + case 245: return true; - case 189: + case 192: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188: + case 191: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186: - case 187: + case 189: + case 190: switch (node.operator) { case 50: case 36: @@ -30742,9 +31766,9 @@ var ts; return true; } return false; - case 184: - case 178: - case 196: + case 187: + case 181: + case 199: default: return false; } @@ -30764,7 +31788,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 172 || left.kind === 171)) { + if (operator === 57 && (left.kind === 175 || left.kind === 174)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -30921,8 +31945,7 @@ var ts; } function checkAssignmentOperator(valueType) { if (produceDiagnostics && operator >= 57 && operator <= 69) { - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); - if (ok) { + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } } @@ -30948,7 +31971,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 65536) || isYieldExpressionInClass(node)) { + if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -31022,8 +32045,8 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = skipParenthesizedNodes(node); - return node.kind === 178 || node.kind === 196; + node = ts.skipParentheses(node); + return node.kind === 181 || node.kind === 199; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -31049,14 +32072,14 @@ var ts; return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -31079,7 +32102,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140) { + if (node.kind === 141) { type = checkQualifiedName(node); } else { @@ -31087,9 +32110,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 173 && node.parent.expression === node) || - (node.parent.kind === 174 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 140) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 176 && node.parent.expression === node) || + (node.parent.kind === 177 && node.parent.expression === node) || + ((node.kind === 70 || node.kind === 141) && isInRightSideOfImportOrExportAssignment(node)); 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); } @@ -31111,66 +32134,66 @@ var ts; case 100: case 85: return checkLiteralExpression(node); - case 190: + case 193: return checkTemplateExpression(node); case 12: return stringType; case 11: return globalRegExpType; - case 171: - return checkArrayLiteral(node, contextualMapper); - case 172: - return checkObjectLiteral(node, contextualMapper); - case 173: - return checkPropertyAccessExpression(node); case 174: - return checkIndexedAccess(node); + return checkArrayLiteral(node, contextualMapper); case 175: + return checkObjectLiteral(node, contextualMapper); case 176: - return checkCallExpression(node); + return checkPropertyAccessExpression(node); case 177: - return checkTaggedTemplateExpression(node); - case 179: - return checkExpression(node.expression, contextualMapper); - case 193: - return checkClassExpression(node); - case 180: - case 181: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183: - return checkTypeOfExpression(node); + return checkIndexedAccess(node); case 178: - case 196: - return checkAssertion(node); - case 197: - return checkNonNullAssertion(node); + case 179: + return checkCallExpression(node); + case 180: + return checkTaggedTemplateExpression(node); case 182: - return checkDeleteExpression(node); + return checkExpression(node.expression, contextualMapper); + case 196: + return checkClassExpression(node); + case 183: case 184: - return checkVoidExpression(node); - case 185: - return checkAwaitExpression(node); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 186: - return checkPrefixUnaryExpression(node); + return checkTypeOfExpression(node); + case 181: + case 199: + return checkAssertion(node); + case 200: + return checkNonNullAssertion(node); + case 185: + return checkDeleteExpression(node); case 187: - return checkPostfixUnaryExpression(node); + return checkVoidExpression(node); case 188: - return checkBinaryExpression(node, contextualMapper); + return checkAwaitExpression(node); case 189: - return checkConditionalExpression(node, contextualMapper); - case 192: - return checkSpreadElementExpression(node, contextualMapper); - case 194: - return undefinedWideningType; + return checkPrefixUnaryExpression(node); + case 190: + return checkPostfixUnaryExpression(node); case 191: + return checkBinaryExpression(node, contextualMapper); + case 192: + return checkConditionalExpression(node, contextualMapper); + case 195: + return checkSpreadExpression(node, contextualMapper); + case 197: + return undefinedWideningType; + case 194: return checkYieldExpression(node); - case 248: + case 251: return checkJsxExpression(node); - case 242: + case 245: return checkJsxElement(node); - case 243: + case 246: return checkJsxSelfClosingElement(node); - case 244: + case 247: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -31191,7 +32214,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 149 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 150 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -31202,7 +32225,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 149 || func.kind === 153 || func.kind === 158) { + if (func.kind === 150 || func.kind === 154 || func.kind === 159) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -31214,9 +32237,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 148 || - node.kind === 221 || - node.kind === 180; + return node.kind === 149 || + node.kind === 224 || + node.kind === 183; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -31257,9 +32280,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_21 = _a[_i].name; - if (ts.isBindingPattern(name_21) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_21, parameterName, typePredicate.parameterName)) { + var name_24 = _a[_i].name; + if (ts.isBindingPattern(name_24) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -31272,16 +32295,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181: - case 152: - case 221: - case 180: - case 157: + case 184: + case 153: + case 224: + case 183: + case 158: + case 149: case 148: - case 147: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + var parent_11 = node.parent; + if (node === parent_11.type) { + return parent_11; } } } @@ -31291,27 +32314,27 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_22 = element.name; - if (name_22.kind === 70 && - name_22.text === predicateVariableName) { + var name_25 = element.name; + if (name_25.kind === 70 && + name_25.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_22.kind === 169 || - name_22.kind === 168) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, predicateVariableNode, predicateVariableName)) { + else if (name_25.kind === 172 || + name_25.kind === 171) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_25, predicateVariableNode, predicateVariableName)) { return true; } } } } function checkSignatureDeclaration(node) { - if (node.kind === 154) { + if (node.kind === 155) { checkGrammarIndexSignature(node); } - else if (node.kind === 157 || node.kind === 221 || node.kind === 158 || - node.kind === 152 || node.kind === 149 || - node.kind === 153) { + else if (node.kind === 158 || node.kind === 224 || node.kind === 159 || + node.kind === 153 || node.kind === 150 || + node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -31323,10 +32346,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 153: + case 154: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 152: + case 153: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -31357,7 +32380,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149) { + if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -31371,13 +32394,13 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 150: + case 151: addName(names, member.name, memberName, 1); break; - case 151: + case 152: addName(names, member.name, memberName, 2); break; - case 146: + case 147: addName(names, member.name, memberName, 3); break; } @@ -31403,7 +32426,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 145) { + if (member.kind == 146) { var memberName = void 0; switch (member.name.kind) { case 9: @@ -31425,7 +32448,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223) { + if (node.kind === 226) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -31440,7 +32463,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 133: + case 134: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -31448,7 +32471,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131: + case 132: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -31507,12 +32530,12 @@ var ts; if (n.kind === 98) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 180 && n.kind !== 221) { + else if (n.kind !== 183 && n.kind !== 224) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 && + return n.kind === 147 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -31532,7 +32555,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -31555,18 +32578,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 150) { + if (node.kind === 151) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 150 ? 151 : 150; + var otherKind = node.kind === 151 ? 152 : 151; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -31580,11 +32603,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 150) { + if (node.kind === 151) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 172) { + if (node.parent.kind !== 175) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -31665,14 +32688,17 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 223 && - n.parent.kind !== 222 && - n.parent.kind !== 193 && + if (n.parent.kind !== 226 && + n.parent.kind !== 225 && + n.parent.kind !== 196 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -31749,7 +32775,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 148 || node.kind === 147) && + var reportError = (node.kind === 149 || node.kind === 148) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -31782,11 +32808,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 223 || node.parent.kind === 160 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 226 || node.parent.kind === 161 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 221 || node.kind === 148 || node.kind === 147 || node.kind === 149) { + if (node.kind === 224 || node.kind === 149 || node.kind === 148 || node.kind === 150) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -31897,16 +32923,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223: - return 2097152; case 226: + return 2097152; + case 229: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 222: case 225: + case 228: return 2097152 | 1048576; - case 230: + case 233: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -31998,51 +33024,50 @@ var ts; } } } - function checkCorrectPromiseType(returnType, location, diagnostic, typeName) { - if (returnType === unknownType) { - return unknownType; - } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType === emptyGenericType - || globalPromiseType === getTargetType(returnType)) { - return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - error(location, diagnostic, typeName); - return unknownType; - } function checkAsyncFunctionReturnType(node) { + var returnType = getTypeFromTypeNode(node.type); if (languageVersion >= 2) { - var returnType = getTypeFromTypeNode(node.type); - return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - return unknownType; + else { + markTypeNodeAsReferenced(node.type); + if (returnType === unknownType) { + return unknownType; + } + var promiseConstructorName = ts.getEntityNameFromTypeNode(node.type); + if (promiseConstructorName === undefined) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); + return unknownType; + } + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; + if (promiseConstructorType === unknownType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { + return unknownType; + } + var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var collidingSymbol = getSymbol(node.locals, rootName.text, 107455); + if (collidingSymbol) { + error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, rootName.text, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } } - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - return unknownType; - } - var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - var typeName = promiseConstructor - ? symbolToString(promiseConstructor) - : typeToString(promiseType); - return checkCorrectPromiseType(promiseType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); - } - checkReturnTypeAnnotationAsExpression(node); - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, 107455); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseNameOrNamespaceRoot.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; - } - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -32054,22 +33079,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222: + case 225: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 143: + case 144: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 146: + case 147: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 148: - case 150: + case 149: case 151: + case 152: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -32077,29 +33102,15 @@ var ts; } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } - function checkTypeNodeAsExpression(node) { - if (node && node.kind === 156) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 156 ? 793064 : 1920; - var rootSymbol = resolveName(root, root.text, meaning | 8388608, undefined, undefined); - if (rootSymbol && rootSymbol.flags & 8388608) { - var aliasTarget = resolveAlias(rootSymbol); - if (aliasTarget.flags & 107455 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } - function checkTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkReturnTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkParameterTypeAnnotationsAsExpressions(node) { - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); + function markTypeNodeAsReferenced(node) { + var typeName = node && ts.getEntityNameFromTypeNode(node); + var rootName = typeName && getFirstIdentifier(typeName); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + if (rootSymbol + && rootSymbol.flags & 8388608 + && symbolIsValue(rootSymbol) + && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } function checkDecorators(node) { @@ -32114,21 +33125,27 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 222: + case 225: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); + for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + markTypeNodeAsReferenced(parameter.type); + } } break; - case 148: - case 150: + case 149: case 151: - checkParameterTypeAnnotationsAsExpressions(node); - checkReturnTypeAnnotationAsExpression(node); + case 152: + for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + markTypeNodeAsReferenced(parameter.type); + } + markTypeNodeAsReferenced(node.type); break; - case 146: - case 143: - checkTypeAnnotationAsExpression(node); + case 147: + case 144: + markTypeNodeAsReferenced(node.type); break; } } @@ -32147,7 +33164,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 141) { + if (node.name && node.name.kind === 142) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -32189,43 +33206,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 256: - case 226: + case 260: + case 229: checkUnusedModuleMembers(node); break; - case 222: - case 193: + case 225: + case 196: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223: + case 226: checkUnusedTypeParameters(node); break; - case 200: - case 228: - case 207: - case 208: - case 209: + case 203: + case 231: + case 210: + case 211: + case 212: checkUnusedLocalsAndParameters(node); break; - case 149: - case 180: - case 221: - case 181: - case 148: case 150: + case 183: + case 224: + case 184: + case 149: case 151: + case 152: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 147: - case 152: + case 148: case 153: case 154: - case 157: + case 155: case 158: + case 159: checkUnusedTypeParameters(node); break; } @@ -32234,11 +33251,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { + if (node.parent.kind !== 226 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 143) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -32253,16 +33270,16 @@ var ts; } }; for (var key in node.locals) { - _loop_2(key); + _loop_3(key); } } } function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 219 && - (declaration.parent.parent.kind === 208 || - declaration.parent.parent.kind === 209)) { + if (declaration.kind === 222 && + (declaration.parent.parent.kind === 211 || + declaration.parent.parent.kind === 212)) { return; } } @@ -32279,12 +33296,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 || member.kind === 146) { + if (member.kind === 149 || member.kind === 147) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 149) { + else if (member.kind === 150) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -32329,7 +33346,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 200) { + if (node.kind === 203) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -32351,19 +33368,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 146 || - node.kind === 145 || + if (node.kind === 147 || + node.kind === 146 || + node.kind === 149 || node.kind === 148 || - node.kind === 147 || - node.kind === 150 || - node.kind === 151) { + node.kind === 151 || + node.kind === 152) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 143 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 144 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -32414,11 +33431,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32426,11 +33443,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 226 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 229 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 256 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 260 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { error(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)); } } @@ -32438,7 +33455,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 219 && !node.initializer) { + if (node.kind === 222 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -32448,25 +33465,25 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220); - var container = varDeclList.parent.kind === 201 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 223); + var container = varDeclList.parent.kind === 204 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 200 && ts.isFunctionLike(container.parent) || - container.kind === 227 || - container.kind === 226 || - container.kind === 256); + (container.kind === 203 && ts.isFunctionLike(container.parent) || + container.kind === 230 || + container.kind === 229 || + container.kind === 260); if (!namesShareScope) { - var name_23 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_23, name_23); + var name_26 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_26, name_26); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 143) { + if (ts.getRootDeclaration(node).kind !== 144) { return; } var func = ts.getContainingFunction(node); @@ -32475,7 +33492,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 173) { + if (n.kind === 176) { return visit(n.expression); } else if (n.kind === 70) { @@ -32489,7 +33506,7 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 143) { + if (symbol.valueDeclaration.kind === 144) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -32498,7 +33515,7 @@ var ts; if (ts.isFunctionLike(current.parent)) { return; } - if (current.parent.kind === 146 && + if (current.parent.kind === 147 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)) { return; @@ -32520,33 +33537,34 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 141) { + if (node.name.kind === 142) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 170) { - if (node.propertyName && node.propertyName.kind === 141) { + if (node.kind === 173) { + if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_13 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_13); - var name_24 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_24)); - if (parent_13.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); + var parent_12 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_12); + var name_27 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_27)); + markPropertyAsReferenced(property); + if (parent_12.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 143 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 144 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -32555,7 +33573,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 208) { + if (node.initializer && node.parent.parent.kind !== 211) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -32573,9 +33591,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 146 && node.kind !== 145) { + if (node.kind !== 147 && node.kind !== 146) { checkExportsOnMergedDeclarations(node); - if (node.kind === 219 || node.kind === 170) { + if (node.kind === 222 || node.kind === 173) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -32585,8 +33603,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 143 && right.kind === 219) || - (left.kind === 219 && right.kind === 143)) { + if ((left.kind === 144 && right.kind === 222) || + (left.kind === 222 && right.kind === 144)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -32613,7 +33631,7 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 172) { + if (node.modifiers && node.parent.kind === 175) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -32632,7 +33650,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202) { + if (node.thenStatement.kind === 205) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -32649,12 +33667,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220) { + if (node.initializer && node.initializer.kind === 223) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -32672,18 +33690,18 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); if (iteratedType) { checkTypeAssignableTo(iteratedType, leftType, varExpr, undefined); } @@ -32696,7 +33714,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 220) { + if (node.initializer.kind === 223) { 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); @@ -32706,14 +33724,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 171 || varExpr.kind === 172) { + if (varExpr.kind === 174 || varExpr.kind === 175) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } var rightType = checkNonNullExpression(node.expression); @@ -32879,7 +33897,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 150 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151))); + return !!(node.kind === 151 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -32901,12 +33919,12 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 151) { + if (func.kind === 152) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 149) { + else if (func.kind === 150) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -32924,14 +33942,14 @@ var ts; } } } - else if (func.kind !== 149 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 150 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 262144) { + if (node.flags & 524288) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -32948,8 +33966,9 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); + var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 250 && !hasDuplicateDefaultClause) { + if (clause.kind === 253 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -32961,11 +33980,17 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249) { + if (produceDiagnostics && clause.kind === 252) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); - if (!isTypeEqualityComparableTo(expressionType, caseType)) { - checkTypeComparableTo(caseType, expressionType, caseClause.expression, undefined); + var caseIsLiteral = isLiteralType(caseType); + var comparedExpressionType = expressionType; + if (!caseIsLiteral || !expressionIsLiteral) { + caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType; + comparedExpressionType = getBaseTypeOfLiteralType(expressionType); + } + if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) { + checkTypeComparableTo(caseType, comparedExpressionType, caseClause.expression, undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -32981,7 +34006,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 && current.label.text === node.label.text) { + if (current.kind === 218 && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -33073,7 +34098,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 141 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 142 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -33124,7 +34149,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 || declaration.kind === 223) { + if (declaration.kind === 225 || declaration.kind === 226) { if (!firstDecl) { firstDecl = declaration; } @@ -33189,7 +34214,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 222) { + baseType_1.symbol.valueDeclaration.kind === 225) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -33263,7 +34288,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 193) { + if (derivedClassDecl.kind === 196) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -33307,7 +34332,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 || kind === 151; + return kind === 151 || kind === 152; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -33345,8 +34370,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { - var prop = properties_5[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen[prop.name]; if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; @@ -33374,7 +34399,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 226); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -33420,7 +34445,7 @@ var ts; error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { - var text = getTextOfPropertyName(member.name); + var text = ts.getTextOfPropertyName(member.name); if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } @@ -33470,7 +34495,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186: + case 189: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -33481,7 +34506,7 @@ var ts; case 51: return ~value_1; } return undefined; - case 188: + case 191: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -33506,11 +34531,11 @@ var ts; return undefined; case 8: return +e.text; - case 179: + case 182: return evalConstant(e.expression); case 70: - case 174: - case 173: + case 177: + case 176: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -33521,7 +34546,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174) { + if (e.kind === 177) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -33538,7 +34563,7 @@ var ts; if (current.kind === 70) { break; } - else if (current.kind === 173) { + else if (current.kind === 176) { current = current.expression; } else { @@ -33598,7 +34623,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 225) { + if (declaration.kind !== 228) { return false; } var enumDeclaration = declaration; @@ -33621,8 +34646,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 222 || - (declaration.kind === 221 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 225 || + (declaration.kind === 224 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -33681,7 +34706,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 222); + var mergedClass = ts.getDeclarationOfKind(symbol, 225); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -33724,36 +34749,36 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201: + case 204: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 236: - case 237: + case 239: + case 240: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230: - case 231: + case 233: + case 234: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 170: - case 219: - var name_25 = node.name; - if (ts.isBindingPattern(name_25)) { - for (var _b = 0, _c = name_25.elements; _b < _c.length; _b++) { + case 173: + case 222: + var name_28 = node.name; + if (ts.isBindingPattern(name_28)) { + for (var _b = 0, _c = name_28.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } - case 222: case 225: - case 221: - case 223: - case 226: + case 228: case 224: + case 226: + case 229: + case 227: if (isGlobalAugmentation) { return; } @@ -33771,12 +34796,12 @@ var ts; switch (node.kind) { case 70: return node; - case 140: + case 141: do { node = node.left; } while (node.kind !== 70); return node; - case 173: + case 176: do { node = node.expression; } while (node.kind !== 70); @@ -33789,9 +34814,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { - error(moduleName, node.kind === 237 ? + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { + error(moduleName, node.kind === 240 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -33812,7 +34837,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 239 ? + var message = node.kind === 242 ? 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)); @@ -33839,7 +34864,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 236) { checkImportBinding(importClause.namedBindings); } else { @@ -33890,8 +34915,8 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 227 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 230 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -33904,7 +34929,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 || node.parent.kind === 227 || node.parent.kind === 226; + var isInAppropriateContext = node.parent.kind === 260 || node.parent.kind === 230 || node.parent.kind === 229; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -33927,8 +34952,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 256 ? node.parent : node.parent.parent; - if (container.kind === 226 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 260 ? node.parent : node.parent.parent; + if (container.kind === 229 && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -33995,7 +35020,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 && declaration.kind !== 148) || + return (declaration.kind !== 224 && declaration.kind !== 149) || !!declaration.body; } } @@ -34006,118 +35031,121 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 229: + case 225: case 226: - case 222: - case 223: - case 221: + case 224: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 142: - return checkTypeParameter(node); case 143: + return checkTypeParameter(node); + case 144: return checkParameter(node); + case 147: case 146: - case 145: return checkPropertyDeclaration(node); - case 157: case 158: - case 152: + case 159: case 153: - return checkSignatureDeclaration(node); case 154: return checkSignatureDeclaration(node); - case 148: - case 147: - return checkMethodDeclaration(node); - case 149: - return checkConstructorDeclaration(node); - case 150: - case 151: - return checkAccessorDeclaration(node); - case 156: - return checkTypeReferenceNode(node); case 155: + return checkSignatureDeclaration(node); + case 149: + case 148: + return checkMethodDeclaration(node); + case 150: + return checkConstructorDeclaration(node); + case 151: + case 152: + return checkAccessorDeclaration(node); + case 157: + return checkTypeReferenceNode(node); + case 156: return checkTypePredicate(node); - case 159: - return checkTypeQuery(node); case 160: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 161: - return checkArrayType(node); + return checkTypeLiteral(node); case 162: - return checkTupleType(node); + return checkArrayType(node); case 163: + return checkTupleType(node); case 164: - return checkUnionOrIntersectionType(node); case 165: + return checkUnionOrIntersectionType(node); + case 166: + case 168: return checkSourceElement(node.type); - case 221: - return checkFunctionDeclaration(node); - case 200: - case 227: - return checkBlock(node); - case 201: - return checkVariableStatement(node); - case 203: - return checkExpressionStatement(node); - case 204: - return checkIfStatement(node); - case 205: - return checkDoStatement(node); - case 206: - return checkWhileStatement(node); - case 207: - return checkForStatement(node); - case 208: - return checkForInStatement(node); - case 209: - return checkForOfStatement(node); - case 210: - case 211: - return checkBreakOrContinueStatement(node); - case 212: - return checkReturnStatement(node); - case 213: - return checkWithStatement(node); - case 214: - return checkSwitchStatement(node); - case 215: - return checkLabeledStatement(node); - case 216: - return checkThrowStatement(node); - case 217: - return checkTryStatement(node); - case 219: - return checkVariableDeclaration(node); - case 170: - return checkBindingElement(node); - case 222: - return checkClassDeclaration(node); - case 223: - return checkInterfaceDeclaration(node); + case 169: + return checkIndexedAccessType(node); case 224: - return checkTypeAliasDeclaration(node); - case 225: - return checkEnumDeclaration(node); - case 226: - return checkModuleDeclaration(node); - case 231: - return checkImportDeclaration(node); + return checkFunctionDeclaration(node); + case 203: case 230: - return checkImportEqualsDeclaration(node); - case 237: - return checkExportDeclaration(node); - case 236: - return checkExportAssignment(node); - case 202: - checkGrammarStatementInAmbientContext(node); - return; + return checkBlock(node); + case 204: + return checkVariableStatement(node); + case 206: + return checkExpressionStatement(node); + case 207: + return checkIfStatement(node); + case 208: + return checkDoStatement(node); + case 209: + return checkWhileStatement(node); + case 210: + return checkForStatement(node); + case 211: + return checkForInStatement(node); + case 212: + return checkForOfStatement(node); + case 213: + case 214: + return checkBreakOrContinueStatement(node); + case 215: + return checkReturnStatement(node); + case 216: + return checkWithStatement(node); + case 217: + return checkSwitchStatement(node); case 218: + return checkLabeledStatement(node); + case 219: + return checkThrowStatement(node); + case 220: + return checkTryStatement(node); + case 222: + return checkVariableDeclaration(node); + case 173: + return checkBindingElement(node); + case 225: + return checkClassDeclaration(node); + case 226: + return checkInterfaceDeclaration(node); + case 227: + return checkTypeAliasDeclaration(node); + case 228: + return checkEnumDeclaration(node); + case 229: + return checkModuleDeclaration(node); + case 234: + return checkImportDeclaration(node); + case 233: + return checkImportEqualsDeclaration(node); + case 240: + return checkExportDeclaration(node); + case 239: + return checkExportAssignment(node); + case 205: checkGrammarStatementInAmbientContext(node); return; - case 240: + case 221: + checkGrammarStatementInAmbientContext(node); + return; + case 243: return checkMissingDeclaration(node); } } @@ -34130,17 +35158,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 180: - case 181: + case 183: + case 184: + case 149: case 148: - case 147: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150: case 151: + case 152: checkAccessorDeferred(node); break; - case 193: + case 196: checkClassExpressionDeferred(node); break; } @@ -34194,8 +35222,19 @@ var ts; function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { + var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); + var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + if (currentGlobalDiagnostics !== previousGlobalDiagnostics) { + var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics); + return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics); + } + else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) { + return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics); + } + return semanticDiagnostics; } ts.forEach(host.getSourceFiles(), checkSourceFile); return diagnostics.getDiagnostics(); @@ -34212,7 +35251,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 && node.parent.statement === node) { + if (node.parent.kind === 216 && node.parent.statement === node) { return true; } node = node.parent; @@ -34234,28 +35273,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256: + case 260: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226: + case 229: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 225: + case 228: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 193: + case 196: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 222: - case 223: + case 225: + case 226: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 180: + case 183: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -34294,27 +35333,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142: - case 222: - case 223: - case 224: + case 143: case 225: + case 226: + case 227: + case 228: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 140) { + while (node.parent && node.parent.kind === 141) { node = node.parent; } - return node.parent && (node.parent.kind === 156 || node.parent.kind === 267); + return node.parent && (node.parent.kind === 157 || node.parent.kind === 271); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173) { + while (node.parent && node.parent.kind === 176) { node = node.parent; } - return node.parent && node.parent.kind === 195; + return node.parent && node.parent.kind === 198; } function forEachEnclosingClass(node, callback) { var result; @@ -34331,13 +35370,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 140) { + while (nodeOnRightSide.parent.kind === 141) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230) { + if (nodeOnRightSide.parent.kind === 233) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 239) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -34349,7 +35388,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 176) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1: @@ -34361,11 +35400,11 @@ var ts; default: } } - if (entityName.parent.kind === 236 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 239 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 173 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 230); + if (entityName.kind !== 176 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 233); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -34374,7 +35413,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 195) { + if (entityName.parent.kind === 198) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -34396,14 +35435,14 @@ var ts; } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 173) { + else if (entityName.kind === 176) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 140) { + else if (entityName.kind === 141) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -34412,19 +35451,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 156 || entityName.parent.kind === 267) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 157 || entityName.parent.kind === 271) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 246) { + else if (entityName.parent.kind === 249) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 155) { + if (entityName.parent.kind === 156) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 256) { + if (node.kind === 260) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -34440,8 +35479,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 170 && - node.parent.parent.kind === 168 && + else if (node.parent.kind === 173 && + node.parent.parent.kind === 171 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -34452,8 +35491,8 @@ var ts; } switch (node.kind) { case 70: - case 173: - case 140: + case 176: + case 141: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98: var container = ts.getThisContainer(node, false); @@ -34466,18 +35505,18 @@ var ts; case 96: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 166: + case 167: return getTypeFromTypeNode(node).symbol; case 122: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 149) { + if (constructorDeclaration && constructorDeclaration.kind === 150) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 231 || node.parent.kind === 237) && + ((node.parent.kind === 234 || node.parent.kind === 240) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -34485,7 +35524,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 174 && node.parent.argumentExpression === node) { + if (node.parent.kind === 177 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -34499,7 +35538,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 254) { + if (location && location.kind === 257) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -34549,20 +35588,20 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 172 || expr.kind === 171); - if (expr.parent.kind === 209) { + ts.Debug.assert(expr.kind === 175 || expr.kind === 174); + if (expr.parent.kind === 212) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 188) { + if (expr.parent.kind === 191) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 253) { + if (expr.parent.kind === 256) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 171); + ts.Debug.assert(expr.parent.kind === 174); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); @@ -34598,9 +35637,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_26 = symbol.name; + var name_29 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_26); + var symbol = getPropertyOfType(t, name_29); if (symbol) { symbols_3.push(symbol); } @@ -34608,6 +35647,10 @@ var ts; return symbols_3; } else if (symbol.flags & 67108864) { + if (symbol.leftSpread) { + var links = symbol; + return [links.leftSpread, links.rightSpread]; + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -34665,7 +35708,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 256) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 260) { var symbolFile = parentSymbol.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -34703,7 +35746,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 200 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 203 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -34743,16 +35786,16 @@ var ts; return true; } switch (node.kind) { - case 230: - case 232: case 233: case 235: - case 239: + case 236: + case 238: + case 242: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237: + case 240: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236: + case 239: return node.expression && node.expression.kind === 70 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -34762,7 +35805,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 256 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 260 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -34813,7 +35856,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255) { + if (node.kind === 259) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -34907,9 +35950,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_14 = reference.parent; - if (ts.isDeclaration(parent_14) && reference === parent_14.name) { - location = getDeclarationContainer(parent_14); + var parent_13 = reference.parent; + if (ts.isDeclaration(parent_13) && reference === parent_13.name) { + location = getDeclarationContainer(parent_13); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -34929,7 +35972,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 262144); + return !!(type.flags & 96 && type.flags & 1048576); } return false; } @@ -34980,13 +36023,14 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - writeLiteralConstValue: writeLiteralConstValue + writeLiteralConstValue: writeLiteralConstValue, + getJsxFactoryEntity: function () { return _jsxFactoryEntity; } }; function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 173) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 176) || (node.kind === 70 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -35008,6 +36052,9 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + return undefined; + } } } return typeReferenceDirectives; @@ -35018,15 +36065,15 @@ var ts; } var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_14 = getParentOfSymbol(current); + if (parent_14) { + current = parent_14; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 260 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -35045,7 +36092,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256); + return ts.getDeclarationOfKind(moduleSymbol, 260); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -35075,7 +36122,7 @@ var ts; } } if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 31744; + var fileRequestedExternalEmitHelpers = file.flags & 64512; if (fileRequestedExternalEmitHelpers) { requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; if (firstFileRequestingExternalHelpers === undefined) { @@ -35144,9 +36191,13 @@ var ts; if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { verifyHelperSymbol(exports_2, "__extends", 107455); } - if (requestedExternalEmitHelpers & 16384 && compilerOptions.jsx !== 1) { + if (requestedExternalEmitHelpers & 16384 && + (languageVersion < 5 || compilerOptions.jsx === 2)) { verifyHelperSymbol(exports_2, "__assign", 107455); } + if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { + verifyHelperSymbol(exports_2, "__rest", 107455); + } if (requestedExternalEmitHelpers & 2048) { verifyHelperSymbol(exports_2, "__decorate", 107455); if (compilerOptions.emitDecoratorMetadata) { @@ -35193,14 +36244,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 148 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 149 && !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 === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { 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); @@ -35217,17 +36268,17 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 129) { - if (node.kind === 145 || node.kind === 147) { + if (modifier.kind !== 130) { + if (node.kind === 146 || node.kind === 148) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 154) { + if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75: - if (node.kind !== 225 && node.parent.kind === 222) { + if (node.kind !== 228 && node.parent.kind === 225) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); } break; @@ -35253,7 +36304,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -35276,10 +36327,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 227 || node.parent.kind === 256) { + else if (node.parent.kind === 230 || node.parent.kind === 260) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -35288,11 +36339,11 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 129: + case 130: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 146 && node.kind !== 145 && node.kind !== 154 && node.kind !== 143) { + else if (node.kind !== 147 && node.kind !== 146 && node.kind !== 155 && node.kind !== 144) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -35311,10 +36362,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; @@ -35326,13 +36377,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 222) { + else if (node.parent.kind === 225) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 230) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -35342,14 +36393,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 222) { - if (node.kind !== 148 && - node.kind !== 146 && - node.kind !== 150 && - node.kind !== 151) { + if (node.kind !== 225) { + if (node.kind !== 149 && + node.kind !== 147 && + node.kind !== 151 && + node.kind !== 152) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 222 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 225 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -35368,7 +36419,7 @@ var ts; else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 143) { + else if (node.kind === 144) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -35376,7 +36427,7 @@ var ts; break; } } - if (node.kind === 149) { + if (node.kind === 150) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -35391,13 +36442,13 @@ var ts; } return; } - else if ((node.kind === 231 || node.kind === 230) && flags & 2) { + else if ((node.kind === 234 || node.kind === 233) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 143 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 144 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 143 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 144 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -35413,37 +36464,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 150: case 151: - case 149: - case 146: - case 145: - case 148: + case 152: + case 150: case 147: - case 154: - case 226: - case 231: - case 230: - case 237: - case 236: - case 180: - case 181: - case 143: + case 146: + case 149: + case 148: + case 155: + case 229: + case 234: + case 233: + case 240: + case 239: + case 183: + case 184: + case 144: return false; default: - if (node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 230 || node.parent.kind === 260) { return false; } switch (node.kind) { - case 221: - return nodeHasAnyModifiersExcept(node, 119); - case 222: - return nodeHasAnyModifiersExcept(node, 116); - case 223: - case 201: case 224: - return true; + return nodeHasAnyModifiersExcept(node, 119); case 225: + return nodeHasAnyModifiersExcept(node, 116); + case 226: + case 204: + case 227: + return true; + case 228: return nodeHasAnyModifiersExcept(node, 75); default: ts.Debug.fail(); @@ -35456,10 +36507,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148: - case 221: - case 180: - case 181: + case 149: + case 224: + case 183: + case 184: if (!node.asteriskToken) { return false; } @@ -35521,7 +36572,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181) { + if (node.kind === 184) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -35556,7 +36607,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 !== 133 && parameter.type.kind !== 131) { + if (parameter.type.kind !== 134 && parameter.type.kind !== 132) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -35583,7 +36634,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 194) { + if (arg.kind === 197) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -35653,19 +36704,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 141) { + if (node.kind !== 142) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 188 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 191 && computedPropertyName.expression.operatorToken.kind === 25) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 221 || - node.kind === 180 || - node.kind === 148); + ts.Debug.assert(node.kind === 224 || + node.kind === 183 || + node.kind === 149); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -35690,42 +36741,45 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_27 = prop.name; - if (name_27.kind === 141) { - checkGrammarComputedPropertyName(name_27); + if (prop.kind === 258) { + continue; } - if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) { + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); + } + if (prop.kind === 257 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 148) { + if (mod.kind !== 119 || prop.kind !== 149) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 253 || prop.kind === 254) { + if (prop.kind === 256 || prop.kind === 257) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + if (name_30.kind === 8) { + checkGrammarNumericLiteral(name_30); } currentKind = Property; } - else if (prop.kind === 148) { + else if (prop.kind === 149) { currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = GetAccessor; } - else if (prop.kind === 151) { + else if (prop.kind === 152) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -35735,18 +36789,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35755,19 +36809,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 247) { + if (attr.kind === 250) { continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 248 && !initializer.expression) { + if (initializer && initializer.kind === 251 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -35776,7 +36830,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220) { + if (forInOrOfStatement.initializer.kind === 223) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -35784,20 +36838,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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 === 208 + var diagnostic = forInOrOfStatement.kind === 211 ? 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); @@ -35821,11 +36875,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 150 ? + return grammarErrorOnNode(accessor.name, kind === 151 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 151) { + else if (kind === 152) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -35844,10 +36898,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 150 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 150 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 151 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -35862,7 +36916,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172) { + if (node.parent.kind === 175) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -35878,10 +36932,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -35892,9 +36946,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215: + case 218: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 210 + var isMisplacedContinueLabel = node.kind === 213 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -35902,8 +36956,8 @@ var ts; return false; } break; - case 214: - if (node.kind === 211 && !node.label) { + case 217: + if (node.kind === 214 && !node.label) { return false; } break; @@ -35916,13 +36970,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 + var message = node.kind === 214 ? 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 === 211 + var message = node.kind === 214 ? 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); @@ -35932,9 +36986,9 @@ var ts; if (node.dotDotDotToken) { var elements = node.parent.elements; if (node !== ts.lastOrUndefined(elements)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 169 || node.name.kind === 168) { + if (node.name.kind === 172 || node.name.kind === 171) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -35944,11 +36998,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 186 && expr.operator === 37 && + expr.kind === 189 && expr.operator === 37 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 208 && node.parent.parent.kind !== 209) { + if (node.parent.parent.kind !== 211 && node.parent.parent.kind !== 212) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -36005,15 +37059,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204: - case 205: - case 206: - case 213: case 207: case 208: case 209: + case 216: + case 210: + case 211: + case 212: return false; - case 215: + case 218: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -36068,7 +37122,7 @@ var ts; return true; } } - else if (node.parent.kind === 223) { + else if (node.parent.kind === 226) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36076,7 +37130,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 160) { + else if (node.parent.kind === 161) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -36089,13 +37143,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 223 || - node.kind === 224 || - node.kind === 231 || - node.kind === 230 || - node.kind === 237 || - node.kind === 236 || - node.kind === 229 || + if (node.kind === 226 || + node.kind === 227 || + node.kind === 234 || + node.kind === 233 || + node.kind === 240 || + node.kind === 239 || + node.kind === 232 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -36104,7 +37158,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 === 201) { + if (ts.isDeclaration(decl) || decl.kind === 204) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -36123,7 +37177,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 200 || node.parent.kind === 227 || node.parent.kind === 256) { + if (node.parent.kind === 203 || node.parent.kind === 230 || node.parent.kind === 260) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -36162,49 +37216,49 @@ var ts; (function (ts) { ; var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[140] = [ + _a[141] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[144] = [ + _a[145] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[178] = [ + _a[181] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196] = [ + _a[199] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197] = [ + _a[200] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225] = [ + _a[228] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226] = [ + _a[229] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227] = [ + _a[230] = [ { name: "statements", test: ts.isStatement } ], - _a[230] = [ + _a[233] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241] = [ + _a[244] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255] = [ + _a[259] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -36217,41 +37271,41 @@ var ts; return initial; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return initial; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return initial; } var result = initial; switch (node.kind) { - case 199: case 202: - case 194: - case 218: - case 287: + case 205: + case 197: + case 221: + case 291: break; - case 141: + case 142: result = reduceNode(node.expression, f, result); break; - case 143: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); - break; case 144: - result = reduceNode(node.expression, f, result); - break; - case 146: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 148: + case 145: + result = reduceNode(node.expression, f, result); + break; + case 147: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = reduceNode(node.type, f, result); + result = reduceNode(node.initializer, f, result); + break; + case 149: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36260,17 +37314,9 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 149: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); - break; case 150: - result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; case 151: @@ -36278,46 +37324,54 @@ var ts; result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 168: - case 169: + case 152: + result = ts.reduceLeft(node.decorators, f, result); + result = ts.reduceLeft(node.modifiers, f, result); + result = reduceNode(node.name, f, result); + result = ts.reduceLeft(node.parameters, f, result); + result = reduceNode(node.body, f, result); + break; + case 171: + case 172: result = ts.reduceLeft(node.elements, f, result); break; - case 170: + case 173: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 171: + case 174: result = ts.reduceLeft(node.elements, f, result); break; - case 172: - result = ts.reduceLeft(node.properties, f, result); - break; - case 173: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); - break; - case 174: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); - break; case 175: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = ts.reduceLeft(node.properties, f, result); break; case 176: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.name, f, result); + break; + case 177: + result = reduceNode(node.expression, f, result); + result = reduceNode(node.argumentExpression, f, result); + break; + case 178: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177: + case 179: + result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.typeArguments, f, result); + result = ts.reduceLeft(node.arguments, f, result); + break; + case 180: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180: + case 183: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -36325,117 +37379,117 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181: + case 184: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 179: case 182: - case 183: - case 184: case 185: - case 191: - case 192: - case 197: - result = reduceNode(node.expression, f, result); - break; case 186: case 187: + case 188: + case 194: + case 195: + case 200: + result = reduceNode(node.expression, f, result); + break; + case 189: + case 190: result = reduceNode(node.operand, f, result); break; - case 188: + case 191: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189: + case 192: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190: + case 193: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193: + case 196: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 195: + case 198: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; - case 198: + case 201: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; - case 200: + case 203: result = ts.reduceLeft(node.statements, f, result); break; - case 201: + case 204: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203: + case 206: result = reduceNode(node.expression, f, result); break; - case 204: + case 207: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205: + case 208: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206: - case 213: + case 209: + case 216: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207: + case 210: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 208: - case 209: + case 211: + case 212: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212: - case 216: + case 215: + case 219: result = reduceNode(node.expression, f, result); break; - case 214: + case 217: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215: + case 218: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217: + case 220: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219: + case 222: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220: + case 223: result = ts.reduceLeft(node.declarations, f, result); break; - case 221: + case 224: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36444,7 +37498,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222: + case 225: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -36452,89 +37506,92 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228: + case 231: result = ts.reduceLeft(node.clauses, f, result); break; - case 231: + case 234: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 232: + case 235: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233: + case 236: result = reduceNode(node.name, f, result); break; - case 234: - case 238: + case 237: + case 241: result = ts.reduceLeft(node.elements, f, result); break; - case 235: - case 239: + case 238: + case 242: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236: + case 239: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237: + case 240: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 242: + case 245: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 243: - case 244: + case 246: + case 247: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245: + case 248: result = reduceNode(node.tagName, f, result); break; - case 246: + case 249: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247: - result = reduceNode(node.expression, f, result); - break; - case 248: - result = reduceNode(node.expression, f, result); - break; - case 249: - result = reduceNode(node.expression, f, result); case 250: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNode(node.expression, f, result); break; case 251: - result = ts.reduceLeft(node.types, f, result); + result = reduceNode(node.expression, f, result); break; case 252: + result = reduceNode(node.expression, f, result); + case 253: + result = ts.reduceLeft(node.statements, f, result); + break; + case 254: + result = ts.reduceLeft(node.types, f, result); + break; + case 255: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; - case 253: + case 256: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254: + case 257: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; - case 256: + case 258: + result = reduceNode(node.expression, f, result); + break; + case 260: result = ts.reduceLeft(node.statements, f, result); break; - case 288: + case 292: result = reduceNode(node.expression, f, result); break; default: @@ -36559,6 +37616,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -36601,6 +37659,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; + aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -36637,178 +37696,180 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 139)) { + if ((kind > 0 && kind <= 140)) { return node; } - if ((kind >= 155 && kind <= 167)) { + if ((kind >= 156 && kind <= 170)) { return node; } switch (node.kind) { - case 199: case 202: - case 194: - case 218: - return node; - case 141: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 143: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 148: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 149: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 150: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 151: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 168: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 171: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 177: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); - case 181: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); - case 182: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 190: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 195: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 200: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); case 205: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 207: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 208: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 209: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 210: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 211: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 212: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 213: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); - case 219: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 220: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 197: case 221: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return node; + case 142: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 144: + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 147: + return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 149: + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 150: + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 151: + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 152: + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 171: + return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); + case 172: + return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); + case 173: + return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 174: + return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); + case 175: + return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 176: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 177: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 178: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 179: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); + case 180: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 182: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 183: + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 184: + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + case 185: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 187: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 188: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 189: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 190: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 192: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 193: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); + case 194: + return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); + case 195: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 196: + return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); + case 198: + return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 201: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 203: + return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); + case 204: + return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 206: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 207: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); + case 208: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 209: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 210: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 211: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 212: + return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 213: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 214: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); + case 215: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); + case 216: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 217: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 218: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); + case 219: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); case 222: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + case 223: + return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); + case 224: + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + case 225: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 228: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 231: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 232: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 233: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 234: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 235: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); case 236: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 237: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); case 238: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 239: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 240: + return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); + case 241: + return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); case 242: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 243: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); case 245: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 246: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 247: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); case 248: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); case 249: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 250: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 251: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 252: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); case 253: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); case 254: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 255: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 256: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 257: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 258: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 260: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 288: + case 292: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -36912,7 +37973,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor) { + function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { var right = node.right; if (ts.isDestructuringAssignment(right)) { @@ -36931,7 +37992,7 @@ var ts; else if (ts.nodeIsSynthesized(node)) { location = value; } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); if (needsValue) { expressions.push(value); } @@ -36949,11 +38010,14 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor, transformRest) { var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, undefined, value, location); @@ -36966,12 +38030,15 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { var declarations = []; var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -37001,33 +38068,39 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { var pendingAssignments = []; - flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, false, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; function emitAssignment(name, value, location, original) { - var left = nameSubstitution && nameSubstitution(name) || name; - emitPendingAssignment(left, value, location, original); + var expression = createAssignmentCallback + ? createAssignmentCallback(name.kind === 70 ? name : emitTempVariableAssignment(name, location), value, location) + : ts.createAssignment(name, value, location); + emitPendingAssignment(expression, original); } function emitTempVariableAssignment(value, location) { var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(name, value, location, undefined); + emitPendingAssignment(ts.createAssignment(name, value, location), undefined); return name; } - function emitPendingAssignment(name, value, location, original) { - var expression = ts.createAssignment(name, value, location); + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectLiteral(elements), value, location, original); + } + function emitPendingAssignment(expression, original) { expression.original = original; ts.setEmitFlags(expression, 2048); pendingAssignments.push(expression); - return expression; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -37058,17 +38131,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172) { + if (target.kind === 175) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171) { + else if (target.kind === 174) { emitArrayLiteralAssignment(target, value, location); } else { - var name_29 = ts.getMutableClone(target); - ts.setSourceMapRange(name_29, target); - ts.setCommentRange(name_29, target); - emitAssignment(name_29, value, location, undefined); + var name_32 = ts.getMutableClone(target); + ts.setSourceMapRange(name_32, target); + ts.setCommentRange(name_32, target); + emitAssignment(name_32, value, location, undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -37076,16 +38149,78 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true, location, emitTempVariableAssignment); } - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; - if (p.kind === 253 || p.kind === 254) { - var propName = p.name; - var target_1 = p.kind === 254 ? p : p.initializer || propName; - emitDestructuringAssignment(target_1, createDestructuringPropertyAccess(value, propName), p); + var bindingElements = []; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 256 || p.kind === 257) { + if (!transformRest || + p.transformFlags & 8388608 || + (p.kind === 256 && p.initializer.transformFlags & 8388608)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 257 ? p : p.initializer || propName; + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && p.kind === 258) { + ts.Debug.assert(p.expression.kind === 70); + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.expression; + var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); + emitDestructuringAssignment(propName, restCall, p); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; } } function emitArrayLiteralAssignment(target, value, location) { + if (transformRest) { + emitESNextArrayLiteralAssignment(target, value, location); + } + else { + emitES2015ArrayLiteralAssignment(target, value, location); + } + } + function emitESNextArrayLiteralAssignment(target, value, location) { + var elements = target.elements; + var numElements = elements.length; + if (numElements !== 1) { + value = ensureIdentifier(value, true, location, emitTempVariableAssignment); + } + var expressions = []; + var spreadContainingExpressions = []; + for (var i = 0; i < numElements; i++) { + var e = elements[i]; + if (e.kind === 197) { + continue; + } + if (e.transformFlags & 8388608 && i < numElements - 1) { + var tmp = ts.createTempVariable(recordTempVariable); + spreadContainingExpressions.push([e, tmp]); + expressions.push(tmp); + } + else { + expressions.push(e); + } + } + emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); + for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { + var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; + emitDestructuringAssignment(e, tmp, e); + } + } + function emitES2015ArrayLiteralAssignment(target, value, location) { var elements = target.elements; var numElements = elements.length; if (numElements !== 1) { @@ -37093,8 +38228,8 @@ var ts; } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 194) { - if (e.kind !== 192) { + if (e.kind !== 197) { + if (e.kind !== 195) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -37103,42 +38238,130 @@ var ts; } } } + function createRestCall(value, elements, getPropertyName, location) { + var propertyNames = []; + for (var i = 0; i < elements.length - 1; i++) { + if (ts.isOmittedExpression(elements[i])) { + continue; + } + var str = ts.createSynthesizedNode(9); + str.pos = location.pos; + str.end = location.end; + str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); + propertyNames.push(str); + } + var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.createIdentifier("__rest"), undefined, args); + } function emitBindingElement(target, value) { var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (initializer) { + if (transformRest) { + value = value || initializer; + } + else if (initializer) { value = value ? createDefaultValueCheck(value, initializer, target) : initializer; } else if (!value) { value = ts.createVoidZero(); } var name = target.name; - if (ts.isBindingPattern(name)) { - var elements = name.elements; - var numElements = elements.length; + if (!ts.isBindingPattern(name)) { + emitAssignment(name, value, target, target); + } + else { + var numElements = name.elements.length; if (numElements !== 1) { value = ensureIdentifier(value, numElements !== 0, target, emitTempVariableAssignment); } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - else if (name.kind === 168) { - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } - else { - if (!element.dotDotDotToken) { - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + if (name.kind === 172) { + emitArrayBindingElement(name, value); + } + else { + emitObjectBindingElement(target, value); } } + } + function emitArrayBindingElement(name, value) { + if (transformRest) { + emitESNextArrayBindingElement(name, value); + } else { - emitAssignment(name, value, target, target); + emitES2015ArrayBindingElement(name, value); + } + } + function emitES2015ArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (!element.dotDotDotToken) { + emitBindingElement(element, ts.createElementAccess(value, i)); + } + else if (i === numElements - 1) { + emitBindingElement(element, ts.createArraySlice(value, i)); + } + } + } + function emitESNextArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + var spreadContainingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (element.transformFlags & 8388608 && i < numElements - 1) { + spreadContainingElements.push(element); + bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + } + else { + bindingElements.push(element); + } + } + emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); + for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { + var element = spreadContainingElements_1[_i]; + emitBindingElement(element, ts.getGeneratedNameForNode(element)); + } + } + function emitObjectBindingElement(target, value) { + var name = target.name; + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (i === numElements - 1 && element.dotDotDotToken) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); + emitBindingElement(element, restCall); + } + else if (transformRest && !(element.transformFlags & 8388608)) { + bindingElements.push(element); + } + else { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var propName = element.propertyName || element.name; + emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; } } function createDefaultValueCheck(value, defaultValue, location) { @@ -37191,14 +38414,14 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(174); + context.enableSubstitution(176); + context.enableSubstitution(177); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -37224,7 +38447,7 @@ var ts; return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 256) { + if (node.kind === 260) { return visitSourceFile(node); } else if (node.transformFlags & 1) { @@ -37240,13 +38463,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231: + case 234: return visitImportDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); - case 236: + case 239: return visitExportAssignment(node); - case 237: + case 240: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -37256,11 +38479,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 237 || - node.kind === 231 || - node.kind === 232 || - (node.kind === 230 && - node.moduleReference.kind === 241)) { + if (node.kind === 240 || + node.kind === 234 || + node.kind === 235 || + (node.kind === 233 && + node.moduleReference.kind === 244)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -37276,21 +38499,30 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 149: - return undefined; - case 146: - case 154: case 150: + return undefined; + case 147: + case 155: case 151: - case 148: + case 152: + case 149: return visitorWorker(node); - case 199: + case 202: return node; default: ts.Debug.failBadSyntaxKind(node); return undefined; } } + function modifierVisitor(node) { + if (ts.modifierToFlag(node.kind) & 2270) { + return undefined; + } + else if (currentNamespace && node.kind === 83) { + return undefined; + } + return node; + } function visitTypeScript(node) { if (ts.hasModifier(node, 2) && ts.isStatement(node)) { return ts.createNotEmittedStatement(node); @@ -37305,78 +38537,80 @@ var ts; case 116: case 75: case 123: - case 129: - case 161: + case 130: case 162: - case 160: - case 155: - case 142: + case 163: + case 161: + case 156: + case 143: case 118: case 121: - case 133: - case 131: - case 128: - case 104: case 134: - case 158: - case 157: + case 132: + case 129: + case 104: + case 135: case 159: - case 156: - case 163: + case 158: + case 160: + case 157: case 164: case 165: case 166: case 167: - case 154: - case 144: - case 224: - case 146: - case 149: - return visitConstructor(node); - case 223: - return ts.createNotEmittedStatement(node); - case 222: - return visitClassDeclaration(node); - case 193: - return visitClassExpression(node); - case 251: - return visitHeritageClause(node); - case 195: - return visitExpressionWithTypeArguments(node); - case 148: - return visitMethodDeclaration(node); + case 168: + case 169: + case 170: + case 155: + case 145: + case 227: + case 147: case 150: - return visitGetAccessor(node); - case 151: - return visitSetAccessor(node); - case 221: - return visitFunctionDeclaration(node); - case 180: - return visitFunctionExpression(node); - case 181: - return visitArrowFunction(node); - case 143: - return visitParameter(node); - case 179: - return visitParenthesizedExpression(node); - case 178: - case 196: - return visitAssertionExpression(node); - case 175: - return visitCallExpression(node); - case 176: - return visitNewExpression(node); - case 197: - return visitNonNullExpression(node); - case 225: - return visitEnumDeclaration(node); - case 201: - return visitVariableStatement(node); - case 219: - return visitVariableDeclaration(node); + return visitConstructor(node); case 226: + return ts.createNotEmittedStatement(node); + case 225: + return visitClassDeclaration(node); + case 196: + return visitClassExpression(node); + case 254: + return visitHeritageClause(node); + case 198: + return visitExpressionWithTypeArguments(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessor(node); + case 152: + return visitSetAccessor(node); + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 182: + return visitParenthesizedExpression(node); + case 181: + case 199: + return visitAssertionExpression(node); + case 178: + return visitCallExpression(node); + case 179: + return visitNewExpression(node); + case 200: + return visitNonNullExpression(node); + case 228: + return visitEnumDeclaration(node); + case 204: + return visitVariableStatement(node); + case 222: + return visitVariableDeclaration(node); + case 229: return visitModuleDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -37385,15 +38619,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 256: - case 228: - case 227: - case 200: + case 260: + case 231: + case 230: + case 203: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222: - case 221: + case 225: + case 224: if (ts.hasModifier(node, 2)) { break; } @@ -37403,10 +38637,11 @@ var ts; } function visitSourceFile(node) { currentSourceFile = node; - if (compilerOptions.alwaysStrict) { + if (compilerOptions.alwaysStrict && + !(ts.isExternalModule(node) && (compilerOptions.target >= 2 || compilerOptions.module === ts.ModuleKind.ES2015))) { node = ts.ensureUseStrict(node); } - if (node.flags & 31744 + if (node.flags & 64512 && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { startLexicalEnvironment(); @@ -37417,10 +38652,10 @@ var ts; externalHelpersModuleImport.parent = node; externalHelpersModuleImport.flags &= ~8; statements.push(externalHelpersModuleImport); - currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; + currentExternalHelpersModuleName = externalHelpersModuleName; ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - currentSourceFileExternalHelpersModuleName = undefined; + currentExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } @@ -37447,66 +38682,59 @@ var ts; var staticProperties = getInitializedProperties(node, true); var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); - var classAlias; var name = node.name; if (!name && staticProperties.length > 0) { name = ts.getGeneratedNameForNode(node); } - var statements = []; - if (!isDecoratedClass) { - var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); - ts.setOriginalNode(classDeclaration, node); - if (staticProperties.length > 0) { - ts.setEmitFlags(classDeclaration, 1024 | ts.getEmitFlags(classDeclaration)); - } - statements.push(classDeclaration); - } - else { - classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); - } + var classStatement = isDecoratedClass + ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) + : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + var statements = [classStatement]; if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, true)); + addInitializedPropertyStatements(statements, staticProperties, ts.getLocalName(node)); } addClassElementDecorationStatements(statements, node, false); addClassElementDecorationStatements(statements, node, true); - addConstructorDecorationStatement(statements, node, classAlias); + addConstructorDecorationStatement(statements, node); if (isNamespaceExport(node)) { addExportMemberAssignment(statements, node); } else if (isDecoratedClass) { if (isDefaultExternalModuleExport(node)) { - statements.push(ts.createExportAssignment(undefined, undefined, false, getLocalName(node))); + statements.push(ts.createExportDefault(ts.getLocalName(node, false, true))); } else if (isNamedExternalModuleExport(node)) { - statements.push(createExternalModuleExport(name)); + statements.push(ts.createExternalModuleExport(ts.getLocalName(node, false, true))); } } - return statements; + if (statements.length > 1) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432); + } + return ts.singleOrMany(statements); } - function addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause) { + function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { + var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var emitFlags = ts.getEmitFlags(node); + if (hasStaticProperties) { + emitFlags |= 1024; + } + ts.setOriginalNode(classDeclaration, node); + ts.setEmitFlags(classDeclaration, emitFlags); + return classDeclaration; + } + function createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) { var location = ts.moveRangePastDecorators(node); - var classExpression = ts.setOriginalNode(ts.createClassExpression(undefined, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), location), node); - if (!name) { - name = ts.getGeneratedNameForNode(node); - } - var classAlias; - if (resolver.getNodeCheckFlags(node) & 8388608) { - enableSubstitutionForClassAliases(); - classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - } - var declaredName = getDeclarationName(node, true); - var transformedClassExpression = ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(classAlias || declaredName, undefined, classExpression) - ]), location); - ts.setCommentRange(transformedClassExpression, node); - statements.push(ts.setOriginalNode(transformedClassExpression, node)); - if (classAlias) { - statements.push(ts.setOriginalNode(ts.createVariableStatement(undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(declaredName, undefined, classAlias) - ]), location), node)); - } - return classAlias; + var classAlias = getClassAliasIfNeeded(node); + var declName = ts.getLocalName(node, false, true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = transformClassMembers(node, hasExtendsClause); + var classExpression = ts.createClassExpression(undefined, name, undefined, heritageClauses, members, location); + ts.setOriginalNode(classExpression, node); + var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setOriginalNode(statement, node); + ts.setCommentRange(statement, node); + return statement; } function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); @@ -37539,7 +38767,7 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 524288; + var hasParameterPropertyAssignments = node.transformFlags & 4194304; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); @@ -37581,7 +38809,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -37615,7 +38843,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 146 + return member.kind === 147 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -37688,12 +38916,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 150: case 151: + case 152: return getAllDecoratorsOfAccessors(node, member); - case 148: + case 149: return getAllDecoratorsOfMethod(member); - case 146: + case 147: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -37771,37 +38999,33 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 146 + ? member.kind === 147 ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); ts.setEmitFlags(helper, 49152); return helper; } - function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { - var expression = generateConstructorDecorationExpression(node, decoratedClassAlias); + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); if (expression) { statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); } } - function generateConstructorDecorationExpression(node, decoratedClassAlias) { + function generateConstructorDecorationExpression(node) { var allDecorators = getAllDecoratorsOfConstructor(node); var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators); if (!decoratorExpressions) { return undefined; } - if (decoratedClassAlias) { - var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); - var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } - else { - var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152); - return result; - } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = ts.getLocalName(node, false, true); + var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 49152); + ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); + return expression; } function transformDecorator(decorator) { return ts.visitNode(decorator.expression, visitor, ts.isExpression); @@ -37812,7 +39036,7 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); + var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); ts.setEmitFlags(helper, 49152); expressions.push(helper); } @@ -37830,13 +39054,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -37844,58 +39068,58 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeParameterTypesOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, undefined, serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); } } } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 148 - || kind === 150 + return kind === 149 || kind === 151 - || kind === 146; + || kind === 152 + || kind === 147; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 148; + return node.kind === 149; } function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 222 - || kind === 193 - || kind === 148 - || kind === 150 - || kind === 151; + return kind === 225 + || kind === 196 + || kind === 149 + || kind === 151 + || kind === 152; } function serializeTypeOfNode(node) { switch (node.kind) { - case 146: - case 143: - case 150: - return serializeTypeNode(node.type); + case 147: + case 144: case 151: + return serializeTypeNode(node.type); + case 152: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 222: - case 193: - case 148: + case 225: + case 196: + case 149: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); } } function getRestParameterElementType(node) { - if (node && node.kind === 161) { + if (node && node.kind === 162) { return node.elementType; } - else if (node && node.kind === 156) { + else if (node && node.kind === 157) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -37943,20 +39167,20 @@ var ts; switch (node.kind) { case 104: return ts.createVoidZero(); - case 165: + case 166: return serializeTypeNode(node.type); - case 157: case 158: + case 159: return ts.createIdentifier("Function"); - case 161: case 162: + case 163: return ts.createIdentifier("Array"); - case 155: + case 156: case 121: return ts.createIdentifier("Boolean"); - case 133: + case 134: return ts.createIdentifier("String"); - case 167: + case 170: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -37970,16 +39194,16 @@ var ts; break; } break; - case 131: + case 132: return ts.createIdentifier("Number"); - case 134: + case 135: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 156: + case 157: return serializeTypeReferenceNode(node); + case 165: case 164: - case 163: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -38003,10 +39227,12 @@ var ts; return serializedUnion; } } - case 159: case 160: + case 168: + case 169: + case 161: case 118: - case 166: + case 167: break; default: ts.Debug.failBadSyntaxKind(node); @@ -38048,15 +39274,15 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_30 = ts.getMutableClone(node); - name_30.flags &= ~8; - name_30.original = undefined; - name_30.parent = currentScope; + var name_33 = ts.getMutableClone(node); + name_33.flags &= ~8; + name_33.original = undefined; + name_33.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_30), ts.createLiteral("undefined")), name_30); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); } - return name_30; - case 140: + return name_33; + case 141: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -38130,7 +39356,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setCommentRange(method, node); ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); ts.setOriginalNode(method, node); @@ -38143,27 +39369,27 @@ var ts; if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitSetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } function visitFunctionDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); if (isNamespaceExport(node)) { var statements = [func]; @@ -38176,12 +39402,12 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); ts.setOriginalNode(func, node); return func; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); ts.setOriginalNode(func, node); return func; } @@ -38228,7 +39454,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameterDeclaration(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); + var parameter = ts.createParameter(undefined, undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression), ts.moveRangePastModifiers(node)); ts.setOriginalNode(parameter, node); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); @@ -38250,7 +39476,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); @@ -38286,39 +39512,32 @@ var ts; || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } - function shouldEmitVarForEnumDeclaration(node) { - return isFirstEmittedDeclarationInScope(node) - && (!ts.hasModifier(node, 1) - || isES6ExportedDeclaration(node)); - } - function addVarForEnumExportedFromNamespace(statements, node) { - var statement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, getExportName(node))]); - ts.setSourceMapRange(statement, node); - statements.push(statement); - } function visitEnumDeclaration(node) { if (!shouldEmitEnumDeclaration(node)) { return undefined; } var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForEnumDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); - var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); + var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); + moduleArg = ts.createAssignment(localName, moduleArg); + } + var enumStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); - if (isNamespaceExport(node)) { - addVarForEnumExportedFromNamespace(statements, node); - } + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformEnumBody(node, localName) { @@ -38353,9 +39572,11 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isES6ExportedDeclaration(node) { - return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES2015; + function hasNamespaceQualifiedExportName(node) { + return isNamespaceExport(node) + || (isExternalModuleExport(node) + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { var name = node.symbol && node.symbol.name; @@ -38370,32 +39591,37 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_31 = node.symbol && node.symbol.name; - if (name_31) { - return currentScopeFirstDeclarationsOfName[name_31] === node; + var name_34 = node.symbol && node.symbol.name; + if (name_34) { + return currentScopeFirstDeclarationsOfName[name_34] === node; } } return false; } - function shouldEmitVarForModuleDeclaration(node) { - return isFirstEmittedDeclarationInScope(node); - } function addVarForEnumOrModuleDeclaration(statements, node) { - var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) - ? ts.visitNodes(node.modifiers, visitor, ts.isModifier) - : undefined, [ - ts.createVariableDeclaration(getDeclarationName(node, false, true)) + var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), [ + ts.createVariableDeclaration(ts.getLocalName(node, false, true)) ]); ts.setOriginalNode(statement, node); - if (node.kind === 225) { - ts.setSourceMapRange(statement.declarationList, node); + recordEmittedDeclarationInScope(node); + if (isFirstEmittedDeclarationInScope(node)) { + if (node.kind === 228) { + ts.setSourceMapRange(statement.declarationList, node); + } + else { + ts.setSourceMapRange(statement, node); + } + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 | 33554432); + statements.push(statement); + return true; } else { - ts.setSourceMapRange(statement, node); + var mergeMarker = ts.createMergeDeclarationMarker(statement); + ts.setEmitFlags(mergeMarker, 49152 | 33554432); + statements.push(mergeMarker); + return false; } - ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768); - statements.push(statement); } function visitModuleDeclaration(node) { if (!shouldEmitModuleDeclaration(node)) { @@ -38405,25 +39631,26 @@ var ts; enableSubstitutionForNamespaceExports(); var statements = []; var emitFlags = 64; - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForModuleDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384; } } var parameterName = getNamespaceParameterName(node); var containerName = getNamespaceContainerName(node); - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true) + : ts.getLocalName(node, false, true); var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); - if (ts.hasModifier(node, 1) && !isES6ExportedDeclaration(node)) { - var localName = getLocalName(node); + if (hasNamespaceQualifiedExportName(node)) { + var localName = ts.getLocalName(node, false, true); moduleArg = ts.createAssignment(localName, moduleArg); } - var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); + var moduleStatement = ts.createStatement(ts.createCall(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]), node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } function transformModuleBody(node, namespaceLocalName) { @@ -38438,7 +39665,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227) { + if (body.kind === 230) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -38461,13 +39688,13 @@ var ts; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); - if (body.kind !== 227) { + if (body.kind !== 230) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226) { + if (moduleDeclaration.body.kind === 229) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -38487,7 +39714,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 233) { + if (node.kind === 236) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -38539,8 +39766,8 @@ var ts; var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); ts.setEmitFlags(moduleReference, 49152 | 65536); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ - ts.createVariableDeclaration(node.name, undefined, moduleReference) + return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) ]), node), node); } else { @@ -38565,36 +39792,20 @@ var ts; return ts.createStatement(expression, undefined); } function addExportMemberAssignment(statements, node) { - var expression = ts.createAssignment(getExportName(node), getLocalName(node, true)); + var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(getNamespaceMemberName(exportName, false, true), exportValue), location); + return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue), location); } - function createExternalModuleExport(exportName) { - return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ - ts.createExportSpecifier(exportName) - ])); - } - function getNamespaceMemberName(name, allowComments, allowSourceMaps) { - var qualifiedName = ts.createPropertyAccess(currentNamespaceContainerName, ts.getSynthesizedClone(name), name); - var emitFlags; - if (!allowComments) { - emitFlags |= 49152; - } - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (emitFlags) { - ts.setEmitFlags(qualifiedName, emitFlags); - } - return qualifiedName; + function createNamespaceExportExpression(exportName, exportValue, location) { + return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { - return getNamespaceMemberName(name, false, true); + return ts.getNamespaceMemberName(currentNamespaceContainerName, name, false, true); } function getNamespaceParameterName(node) { var name = ts.getGeneratedNameForNode(node); @@ -38604,40 +39815,21 @@ var ts; function getNamespaceContainerName(node) { return ts.getGeneratedNameForNode(node); } - function getLocalName(node, noSourceMaps, allowComments) { - return getDeclarationName(node, allowComments, !noSourceMaps, 262144); - } - function getExportName(node, noSourceMaps, allowComments) { - if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); - } - return getDeclarationName(node, allowComments, !noSourceMaps, 131072); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name) { - var name_32 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_32, emitFlags); - } - return name_32; - } - else { - return ts.getGeneratedNameForNode(node); + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 8388608) { + enableSubstitutionForClassAliases(); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; } } function getClassPrototype(node) { - return ts.createPropertyAccess(getDeclarationName(node), "prototype"); + return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { return ts.hasModifier(member, 32) - ? getDeclarationName(node) + ? ts.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { @@ -38657,15 +39849,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(70); - context.enableSubstitution(254); - context.enableEmitNotification(226); + context.enableSubstitution(257); + context.enableEmitNotification(229); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226; + return ts.getOriginalNode(node).kind === 229; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225; + return ts.getOriginalNode(node).kind === 228; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -38690,14 +39882,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_35 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_35); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_35, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_35, exportedName, node); } } return node; @@ -38706,9 +39898,9 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); } return node; @@ -38736,11 +39928,11 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144) === 0) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container) { - var substitute = (applicableSubstitutions & 2 && container.kind === 226) || - (applicableSubstitutions & 8 && container.kind === 225); + if (container && container.kind !== 260) { + var substitute = (applicableSubstitutions & 2 && container.kind === 229) || + (applicableSubstitutions & 8 && container.kind === 228); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, node); } @@ -38811,11 +40003,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242: + case 245: return visitJsxElement(node, false); - case 243: + case 246: return visitJsxSelfClosingElement(node, false); - case 248: + case 251: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -38826,11 +40018,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 248: + case 251: return visitJsxExpression(node); - case 242: + case 245: return visitJsxElement(node, true); - case 243: + case 246: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -38860,7 +40052,7 @@ var ts; objectProperties = ts.singleOrUndefined(segments) || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -38882,7 +40074,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, node) : node; } - else if (node.kind === 248) { + else if (node.kind === 251) { return visitJsxExpression(node); } else { @@ -38947,16 +40139,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242) { + if (node.kind === 245) { return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_36 = node.tagName; + if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { + return ts.createLiteral(name_36.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_36); } } } @@ -39233,6 +40425,163 @@ var ts; } })(ts || (ts = {})); var ts; +(function (ts) { + function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + currentSourceFile = node; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16) { + return visitorWorker(node); + } + else if (node.transformFlags & 32) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 175: + return visitObjectLiteralExpression(node); + case 191: + return visitBinaryExpression(node); + case 222: + return visitVariableDeclaration(node); + case 212: + return visitForOfStatement(node); + case 171: + case 172: + return node; + case 224: + return visitFunctionDeclaration(node); + case 183: + return visitFunctionExpression(node); + case 184: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 258) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 256) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 175) { + objects.unshift(ts.createObjectLiteral()); + } + return ts.createCall(ts.createIdentifier("__assign"), undefined, objects); + } + function visitBinaryExpression(node) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, visitor, true); + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48) { + var result = ts.flattenVariableDestructuring(node, undefined, visitor, undefined, true); + return result; + } + return ts.visitEachChild(node, visitor, context); + } + function visitForOfStatement(node) { + var initializer = node.initializer; + if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { + return ts.visitEachChild(node, visitor, context); + } + return ts.convertForOf(node, undefined, visitor, ts.noop, context, true); + } + function isRestBindingPattern(initializer) { + if (ts.isVariableDeclarationList(initializer)) { + var declaration = ts.firstOrUndefined(initializer.declarations); + return declaration && declaration.name && + declaration.name.kind === 171 && + !!(declaration.name.transformFlags & 8388608); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 175 && + initializer.transformFlags & 8388608; + } + function visitParameter(node) { + if (isObjectRestParameter(node)) { + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, node.initializer, node), node); + } + else { + return node; + } + } + function isObjectRestParameter(node) { + return node.name && + node.name.kind === 171 && + !!(node.name.transformFlags & 8388608); + } + function visitFunctionDeclaration(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + function visitArrowFunction(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + var func = ts.setOriginalNode(ts.createArrowFunction(undefined, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, body, node), node); + ts.setEmitFlags(func, 256); + return func; + } + function visitFunctionExpression(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); + } + } + ts.transformESNext = transformESNext; +})(ts || (ts = {})); +var ts; (function (ts) { function transformES2017(context) { var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; @@ -39257,10 +40606,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16) { + if (node.transformFlags & 64) { return visitorWorker(node); } - else if (node.transformFlags & 32) { + else if (node.transformFlags & 128) { return ts.visitEachChild(node, visitor, context); } return node; @@ -39269,15 +40618,15 @@ var ts; switch (node.kind) { case 119: return undefined; - case 185: + case 188: return visitAwaitExpression(node); - case 148: + case 149: return visitMethodDeclaration(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 181: + case 184: return visitArrowFunction(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39342,9 +40691,10 @@ var ts; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformAsyncFunctionBody(node) { - var nodeType = node.original ? node.original.type : node.type; + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 181; + var isArrowFunction = node.kind === 184; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; if (!isArrowFunction) { var statements = []; @@ -39387,12 +40737,14 @@ var ts; } } function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; + if (type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } } } return undefined; @@ -39400,23 +40752,23 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(175); - context.enableSubstitution(173); - context.enableSubstitution(174); - context.enableEmitNotification(222); - context.enableEmitNotification(148); - context.enableEmitNotification(150); - context.enableEmitNotification(151); + context.enableSubstitution(178); + context.enableSubstitution(176); + context.enableSubstitution(177); + context.enableEmitNotification(225); context.enableEmitNotification(149); + context.enableEmitNotification(151); + context.enableEmitNotification(152); + context.enableEmitNotification(150); } } function substituteExpression(node) { switch (node.kind) { - case 173: + case 176: return substitutePropertyAccessExpression(node); - case 174: + case 177: return substituteElementAccessExpression(node); - case 175: + case 178: if (enabledSubstitutions & 1) { return substituteCallExpression(node); } @@ -39459,11 +40811,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 - || kind === 149 - || kind === 148 + return kind === 225 || kind === 150 - || kind === 151; + || kind === 149 + || kind === 151 + || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -39509,10 +40861,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 64) { + if (node.transformFlags & 256) { return visitorWorker(node); } - else if (node.transformFlags & 128) { + else if (node.transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -39521,7 +40873,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188: + case 191: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39634,11 +40986,11 @@ var ts; return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 212 && !node.expression; + return isInConstructorWithCapturedSuper && node.kind === 215 && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 256) !== 0 || - node.kind === 215 || + return (node.transformFlags & 1024) !== 0 || + node.kind === 218 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { @@ -39648,7 +41000,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -39667,15 +41019,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212: + case 215: node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201: + case 204: return visitVariableStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 211: - case 210: + case 214: + case 213: return visitBreakOrContinueStatement(node); case 98: return visitThisKeyword(node); @@ -39687,76 +41039,76 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83: - return node; - case 222: + case 114: + return undefined; + case 225: return visitClassDeclaration(node); - case 193: + case 196: return visitClassExpression(node); - case 143: + case 144: return visitParameter(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 181: + case 184: return visitArrowFunction(node); - case 180: + case 183: return visitFunctionExpression(node); - case 219: + case 222: return visitVariableDeclaration(node); case 70: return visitIdentifier(node); - case 220: + case 223: return visitVariableDeclarationList(node); - case 215: + case 218: return visitLabeledStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 207: - return visitForStatement(node); case 208: - return visitForInStatement(node); + return visitDoStatement(node); case 209: + return visitWhileStatement(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: return visitForOfStatement(node); - case 203: + case 206: return visitExpressionStatement(node); - case 172: - return visitObjectLiteralExpression(node); - case 252: - return visitCatchClause(node); - case 254: - return visitShorthandPropertyAssignment(node); - case 171: - return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 255: + return visitCatchClause(node); + case 257: + return visitShorthandPropertyAssignment(node); + case 174: + return visitArrayLiteralExpression(node); + case 178: return visitCallExpression(node); - case 176: - return visitNewExpression(node); case 179: + return visitNewExpression(node); + case 182: return visitParenthesizedExpression(node, true); - case 188: + case 191: return visitBinaryExpression(node, true); case 12: case 13: case 14: case 15: return visitTemplateLiteral(node); - case 177: + case 180: return visitTaggedTemplateExpression(node); - case 190: + case 193: return visitTemplateExpression(node); - case 191: + case 194: return visitYieldExpression(node); case 96: return visitSuperKeyword(); - case 191: + case 194: return ts.visitEachChild(node, visitor, context); - case 148: + case 149: return visitMethodDeclaration(node); - case 256: + case 260: return visitSourceFileNode(node); - case 201: + case 204: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39771,7 +41123,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181) { + if (currentNode.kind !== 184) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152)) { enclosingNonAsyncFunctionBody = currentNode; @@ -39779,14 +41131,14 @@ var ts; } } switch (currentNode.kind) { - case 201: + case 204: enclosingVariableStatement = currentNode; break; - case 220: - case 219: - case 170: - case 168: - case 169: + case 223: + case 222: + case 173: + case 171: + case 172: break; default: enclosingVariableStatement = undefined; @@ -39814,7 +41166,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181) { + if (enclosingFunction && enclosingFunction.kind === 184) { convertedLoopState.containsLexicalThis = true; return node; } @@ -39834,13 +41186,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 211 ? 2 : 4; + var jump = node.kind === 214 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 211) { + if (node.kind === 214) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -39850,7 +41202,7 @@ var ts; } } else { - if (node.kind === 211) { + if (node.kind === 214) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -39880,26 +41232,26 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitClassDeclaration(node) { - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1; - var isDefault = modifierFlags & 512; - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, true), undefined, transformClassLikeDeclarationToExpression(node)) - ]), node); + var variable = ts.createVariableDeclaration(ts.getLocalName(node, true), undefined, transformClassLikeDeclarationToExpression(node)); + ts.setOriginalNode(variable, node); + var statements = []; + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([variable]), node); ts.setOriginalNode(statement, node); ts.startOnNewLine(statement); - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment(undefined, undefined, false, getDeclarationName(node, false))); - return statements; + statements.push(statement); + if (ts.hasModifier(node, 1)) { + var exportStatement = ts.hasModifier(node, 512) + ? ts.createExportDefault(ts.getLocalName(node)) + : ts.createExternalModuleExport(ts.getLocalName(node)); + ts.setOriginalNode(exportStatement, statement); + statements.push(exportStatement); } - return statement; - } - function isExportModifier(node) { - return node.kind === 83; + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 33554432) === 0) { + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statement, emitFlags | 33554432); + } + return ts.singleOrMany(statements); } function visitClassExpression(node) { return transformClassLikeDeclarationToExpression(node); @@ -39909,7 +41261,7 @@ var ts; enableSubstitutionsForBlockScopedBindings(); } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); - var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); + var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); if (ts.getEmitFlags(node) & 524288) { ts.setEmitFlags(classFunction, 524288); } @@ -39930,7 +41282,7 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = getLocalName(node); + var localName = ts.getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 49152); @@ -39945,13 +41297,13 @@ var ts; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), extendsClauseElement)); + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 256); } @@ -39974,8 +41326,8 @@ var ts; statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); } if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, false); + ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -40002,17 +41354,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 212) { + if (statement.kind === 215) { return true; } - else if (statement.kind === 204) { + else if (statement.kind === 207) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200) { + else if (statement.kind === 203) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -40023,7 +41375,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0; } @@ -40032,7 +41384,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -40041,7 +41393,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 203 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 206 && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -40050,7 +41402,7 @@ var ts; statements.push(ts.createReturn(superCallExpression)); return 2; } - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); if (superCallExpression) { return 1; } @@ -40067,111 +41419,33 @@ var ts; return undefined; } else if (ts.isBindingPattern(node.name)) { - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, undefined, node), node); } else if (node.initializer) { - return ts.setOriginalNode(ts.createParameter(node.name, undefined, node), node); + return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, node.name, undefined, undefined, undefined, node), node); } else { return node; } } - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 262144) !== 0; - } - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); - } - } - } - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); - } - } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536), ts.setEmitFlags(initializer, 1536 | ts.getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); - } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; - } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536); - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) - ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 65536 && node.kind !== 181) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 | 8388608); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 199: + case 202: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 148: + case 149: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 149: + case 150: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40236,7 +41510,7 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 32768) { + if (node.transformFlags & 262144) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, node, undefined); @@ -40247,80 +41521,22 @@ var ts; return transformFunctionLikeToExpression(node, node, node.name); } function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node), node); + return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), node), node); } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181) { + if (node.kind !== 184) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } - function transformFunctionBody(node) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 181); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, body); - ts.setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 179: + case 182: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 188: + case 191: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -40328,9 +41544,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (needsDestructuringValue) { switch (node.expression.kind) { - case 179: + case 182: return ts.createParen(visitParenthesizedExpression(node.expression, true), node); - case 188: + case 191: return ts.createParen(visitBinaryExpression(node.expression, true), node); } } @@ -40376,7 +41592,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 + if (node.transformFlags & 67108864 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -40395,8 +41611,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 - && enclosingBlockScopeContainer.kind !== 209 + && enclosingBlockScopeContainer.kind !== 211 + && enclosingBlockScopeContainer.kind !== 212 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -40458,68 +41674,7 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(undefined); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, initializer); - ts.setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement(undefined, declarationList)); - } - else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), ts.moveRangeEnd(initializer, -1))); - } - } - else { - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, false, hoistVariableDeclaration, visitor))); - } - else { - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } - ts.setEmitFlags(expression, 1536 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); - ts.setEmitFlags(body, 1536 | 12288); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); - ts.setEmitFlags(forStatement, 8192); - return forStatement; + return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, false); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -40527,8 +41682,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 - || property.name.kind === 141) { + if (property.transformFlags & 134217728 + || property.name.kind === 142) { numInitialProperties = i; break; } @@ -40583,11 +41738,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207: - case 208: - case 209: + case 210: + case 211: + case 212: var initializer = node.initializer; - if (initializer && initializer.kind === 220) { + if (initializer && initializer.kind === 223) { loopInitializer = initializer; } break; @@ -40626,7 +41781,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 16777216) !== 0; + && (node.statement.transformFlags & 134217728) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256; @@ -40634,9 +41789,9 @@ var ts; if (isAsyncBlockContainingAwait) { loopBodyFlags |= 2097152; } - var convertedLoopVariable = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ])); + ]), 16777216)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -40694,7 +41849,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 + statements.push(currentParent.kind === 218 ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -40793,7 +41948,7 @@ var ts; } } else { - loopParameters.push(ts.createParameter(name)); + loopParameters.push(ts.createParameter(undefined, undefined, undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152) { var outParamName = ts.createUniqueName("out_" + name.text); loopOutParameters.push({ originalName: name, outParamName: outParamName }); @@ -40806,20 +41961,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 150: case 151: + case 152: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; - case 253: + case 256: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254: + case 257: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148: + case 149: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -40889,7 +42044,7 @@ var ts; ts.setEmitFlags(thisArg, 128); } var resultingCall; - if (node.transformFlags & 1048576) { + if (node.transformFlags & 8388608) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { @@ -40906,35 +42061,35 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 1048576) !== 0); + ts.Debug.assert((node.transformFlags & 8388608) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) { var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 174 ? ts.createArraySlice(segments[0]) : segments[0]; } return ts.createArrayConcat(segments.shift(), segments); } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function partitionSpread(node) { + return ts.isSpreadExpression(node) + ? visitSpanOfSpreads + : visitSpanOfNonSpreads; } - function visitSpanOfSpreadElements(chunk) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function visitSpanOfSpreads(chunk) { + return ts.map(chunk, visitExpressionOfSpread); } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); } - function visitExpressionOfSpreadElement(node) { + function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } function visitTemplateLiteral(node) { @@ -41007,7 +42162,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32) - && currentParent.kind !== 175 + && currentParent.kind !== 178 ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -41016,7 +42171,7 @@ var ts; var statements = []; startLexicalEnvironment(); ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); + ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); ts.addRange(statements, endLexicalEnvironment()); var clone = ts.getMutableClone(node); @@ -41041,13 +42196,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(98); - context.enableEmitNotification(149); - context.enableEmitNotification(148); context.enableEmitNotification(150); + context.enableEmitNotification(149); context.enableEmitNotification(151); - context.enableEmitNotification(181); - context.enableEmitNotification(180); - context.enableEmitNotification(221); + context.enableEmitNotification(152); + context.enableEmitNotification(184); + context.enableEmitNotification(183); + context.enableEmitNotification(224); } } function onSubstituteNode(emitContext, node) { @@ -41072,10 +42227,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170: - case 222: + case 173: case 225: - case 219: + case 228: + case 222: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -41107,28 +42262,8 @@ var ts; } return node; } - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144); - } - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_36 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536; - } - if (!allowComments) { - emitFlags |= 49152; - } - if (emitFlags) { - ts.setEmitFlags(name_36, emitFlags); - } - return name_36; - } - return ts.getGeneratedNameForNode(node); - } function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); + var expression = ts.getLocalName(node); return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { @@ -41140,11 +42275,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 206) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 178) { return false; } var callTarget = statementExpression.expression; @@ -41152,7 +42287,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 195) { return false; } var expression = callArgument.expression; @@ -41208,7 +42343,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 4096) { + if (node.transformFlags & 8192) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -41223,10 +42358,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 2048) { + else if (transformFlags & 4096) { return visitGenerator(node); } - else if (transformFlags & 4096) { + else if (transformFlags & 8192) { return ts.visitEachChild(node, visitor, context); } else { @@ -41235,13 +42370,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205: + case 208: return visitDoStatement(node); - case 206: + case 209: return visitWhileStatement(node); - case 214: + case 217: return visitSwitchStatement(node); - case 215: + case 218: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -41249,30 +42384,30 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); - case 150: case 151: + case 152: return visitAccessorDeclaration(node); - case 201: + case 204: return visitVariableStatement(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 211: - return visitBreakStatement(node); case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 214: + return visitBreakStatement(node); + case 213: return visitContinueStatement(node); - case 212: + case 215: return visitReturnStatement(node); default: - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (4096 | 33554432)) { + else if (node.transformFlags & (8192 | 268435456)) { return ts.visitEachChild(node, visitor, context); } else { @@ -41282,21 +42417,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188: - return visitBinaryExpression(node); - case 189: - return visitConditionalExpression(node); case 191: + return visitBinaryExpression(node); + case 192: + return visitConditionalExpression(node); + case 194: return visitYieldExpression(node); - case 171: - return visitArrayLiteralExpression(node); - case 172: - return visitObjectLiteralExpression(node); case 174: - return visitElementAccessExpression(node); + return visitArrayLiteralExpression(node); case 175: + return visitObjectLiteralExpression(node); + case 177: + return visitElementAccessExpression(node); + case 178: return visitCallExpression(node); - case 176: + case 179: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41304,9 +42439,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 221: + case 224: return visitFunctionDeclaration(node); - case 180: + case 183: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -41409,7 +42544,7 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 16777216) { + if (node.transformFlags & 134217728) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -41463,10 +42598,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173: + case 176: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174: + case 177: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -41658,35 +42793,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200: - return transformAndEmitBlock(node); case 203: - return transformAndEmitExpressionStatement(node); - case 204: - return transformAndEmitIfStatement(node); - case 205: - return transformAndEmitDoStatement(node); + return transformAndEmitBlock(node); case 206: - return transformAndEmitWhileStatement(node); + return transformAndEmitExpressionStatement(node); case 207: - return transformAndEmitForStatement(node); + return transformAndEmitIfStatement(node); case 208: - return transformAndEmitForInStatement(node); + return transformAndEmitDoStatement(node); + case 209: + return transformAndEmitWhileStatement(node); case 210: - return transformAndEmitContinueStatement(node); + return transformAndEmitForStatement(node); case 211: - return transformAndEmitBreakStatement(node); - case 212: - return transformAndEmitReturnStatement(node); + return transformAndEmitForInStatement(node); case 213: - return transformAndEmitWithStatement(node); + return transformAndEmitContinueStatement(node); case 214: - return transformAndEmitSwitchStatement(node); + return transformAndEmitBreakStatement(node); case 215: - return transformAndEmitLabeledStatement(node); + return transformAndEmitReturnStatement(node); case 216: - return transformAndEmitThrowStatement(node); + return transformAndEmitWithStatement(node); case 217: + return transformAndEmitSwitchStatement(node); + case 218: + return transformAndEmitLabeledStatement(node); + case 219: + return transformAndEmitThrowStatement(node); + case 220: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); @@ -41970,7 +43105,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 250 && defaultClauseIndex === -1) { + if (clause.kind === 253 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -41980,7 +43115,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 249) { + if (clause.kind === 252) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -42071,7 +43206,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216) !== 0; + return node && (node.transformFlags & 134217728) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -42402,7 +43537,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -42411,7 +43546,7 @@ var ts; } return expression; } - return ts.createNode(194); + return ts.createOmittedExpression(); } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); @@ -42499,7 +43634,7 @@ var ts; var buildResult = buildStatements(); return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) + ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) ]); } function buildStatements() { @@ -42770,8 +43905,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173); - context.enableSubstitution(253); + context.enableSubstitution(176); + context.enableSubstitution(256); return transformSourceFile; function transformSourceFile(node) { return node; @@ -42830,48 +43965,40 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableSubstitution(254); - context.enableEmitNotification(256); + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableSubstitution(257); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; + var currentModuleInfo; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); } function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { + var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); } return updated; @@ -42888,77 +44015,105 @@ var ts; } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - return updateSourceFile(node, [ + return ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(define, undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") + ts.createParameter(undefined, undefined, undefined, "require"), + ts.createParameter(undefined, undefined, undefined, "exports") ].concat(importAliasNames), undefined, transformAsynchronousModuleBody(node)) ]))) - ]); + ], node.statements)); + } + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + var aliasedModuleNames = []; + var unaliasedModuleNames = []; + var importAliasNames = []; + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 128); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; } function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); - if (hasExportStarsToExportValues) { + if (currentModuleInfo.hasExportStarsToExportValues) { ts.setEmitFlags(body, 2); } return body; } function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals) { + if (currentModuleInfo.exportEquals) { if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, exportEquals); + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 12288 | 49152); statements.push(statement); } else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), exportEquals); + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); ts.setEmitFlags(statement, 49152); statements.push(statement); } } } - function visitor(node) { + function sourceElementVisitor(node) { switch (node.kind) { - case 231: + case 234: return visitImportDeclaration(node); - case 230: + case 233: return visitImportEqualsDeclaration(node); - case 237: + case 240: return visitExportDeclaration(node); - case 236: + case 239: return visitExportAssignment(node); - case 201: + case 204: return visitVariableStatement(node); - case 221: + case 224: return visitFunctionDeclaration(node); - case 222: + case 225: return visitClassDeclaration(node); - case 203: - return visitExpressionStatement(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); default: return node; } } function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; + var statements; var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (moduleKind !== ts.ModuleKind.AMD) { if (!node.importClause) { - statements.push(ts.createStatement(createRequireCall(node), node)); + return ts.createStatement(createRequireCall(node), node); } else { var variables = []; @@ -42971,43 +44126,60 @@ var ts; variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node))); } } - statements.push(ts.createVariableStatement(undefined, ts.createConstDeclarationList(variables), node)); + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList(variables, undefined, languageVersion >= 2 ? 2 : 0), node)); } } else if (namespaceDeclaration && ts.isDefaultImport(node)) { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), undefined, ts.getGeneratedNameForNode(node), node) - ]))); + ], undefined, languageVersion >= 2 ? 2 : 0))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); } - addExportImportAssignments(statements, node); return ts.singleOrMany(statements); } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); } - ts.setEmitFlags(node.name, 128); - var statements = []; + return ts.createCall(ts.createIdentifier("require"), undefined, args); + } + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; if (moduleKind !== ts.ModuleKind.AMD) { if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), node)); + statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), node)); } else { - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + statements = ts.append(statements, ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), undefined, createRequireCall(node)) ], undefined, languageVersion >= 2 ? 2 : 0), node)); } } else { if (ts.hasModifier(node, 1)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), node)); + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), node)); } } - addExportImportAssignments(statements, node); - return statements; + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); } function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { + if (!node.moduleSpecifier) { return undefined; } var generatedName = ts.getGeneratedNameForNode(node); @@ -43021,7 +44193,7 @@ var ts; for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), specifier)); + statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), specifier)); } return ts.singleOrMany(statements); } @@ -43037,195 +44209,248 @@ var ts; if (node.isExportEquals) { return undefined; } - var statements = []; - addExportDefault(statements, node.expression, node); - return statements; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, node, true); } else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_38 = names_1[_i]; - addExportMemberAssignments(statements, name_38); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_39 = node.name; - if (ts.isIdentifier(name_39)) { - names.push(name_39); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512)) { - addExportDefault(statements, getDeclarationName(node), node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144), node)); - } - } - function visitVariableStatement(node) { - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 226 || - originalKind === 225 || - originalKind === 222) { - if (!ts.hasModifier(node, 1)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement(undefined, node.declarationList), node); - } - var resultStatements = []; - if (ts.hasModifier(node, 1)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, node, true); } + return ts.singleOrMany(statements); } function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); + var statements; if (ts.hasModifier(node, 1)) { - var isAsync = ts.hasModifier(node, 256); - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name, undefined, node.parameters, undefined, node.body, node), node)); - addExportMemberAssignment(statements, node); + statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, node.parameters, undefined, node.body, node), node)); } else { - statements.push(node); + statements = ts.append(statements, node); } - if (node.name) { - addExportMemberAssignments(statements, node.name); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); + var statements; if (ts.hasModifier(node, 1)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration(undefined, undefined, name, undefined, node.heritageClauses, node.members, node), node)); - addExportMemberAssignment(statements, node); + statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, node.heritageClauses, node.members, node), node)); } else { - statements.push(node); + statements = ts.append(statements, node); } - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); } return ts.singleOrMany(statements); } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 225 || origKind === 226) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 222) { - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1)) { + var modifiers = void 0; + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + } + else { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); + } + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - if (ts.hasModifier(original, 1) && - original.kind === 225 && - ts.isFirstDeclarationOfKind(original, 225)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } } - addExportMemberAssignments(statements, original.name); return statements; } - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement(undefined, [ts.createVariableDeclaration(getDeclarationName(node), undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], node); - ts.setEmitFlags(transformedStatement, 49152); - statements.push(transformedStatement); + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name); + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, location, allowComments) { + if (exportName.text === "default") { + var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); + if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 0) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + function createExportStatement(name, value, location, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value, location) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; } function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; + if (node.kind === 260) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = ts.createMap(); previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; } else { previousOnEmitNode(emitContext, node, emitCallback); @@ -43233,6 +44458,9 @@ var ts; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); + if (node.id && noSubstitution[node.id]) { + return node; + } if (emitContext === 1) { return substituteExpression(node); } @@ -43257,141 +44485,82 @@ var ts; switch (node.kind) { case 70: return substituteExpressionIdentifier(node); - case 188: + case 191: return substituteBinaryExpression(node); - case 187: - case 186: + case 190: + case 189: return substituteUnaryExpression(node); } return node; } function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 260) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name_38 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + } + } + } + return node; } function substituteBinaryExpression(node) { - var left = node.left; - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, node); } - return nestedExportAssignment; + return expression; } } return node; } function substituteUnaryExpression(node) { - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128); - var transformedUnaryExpression = void 0; - if (node.kind === 187) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 ? 58 : 59), ts.createLiteral(1), node); - ts.setEmitFlags(transformedUnaryExpression, 128); + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1), node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; + return expression; } } return node; } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072) !== 0); - if (container) { - if (container.kind === 256) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), node); - } + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; } } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), node); - } - else if (ts.isImportSpecifier(declaration)) { - var name_40 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - var aliasedModuleNames = []; - var unaliasedModuleNames = []; - var importAliasNames = []; - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_1 = externalImports; _b < externalImports_1.length; _b++) { - var importNode = externalImports_1[_b]; - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; } var _a; } @@ -43400,7 +44569,7 @@ var ts; var ts; (function (ts) { function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -43409,696 +44578,58 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(70); - context.enableSubstitution(188); - context.enableSubstitution(186); - context.enableSubstitution(187); - context.enableEmitNotification(256); - var exportFunctionForFileMap = []; + context.enableSubstitution(191); + context.enableSubstitution(189); + context.enableSubstitution(190); + context.enableEmitNotification(260); + var moduleInfoMap = ts.createMap(); + var deferredExports = ts.createMap(); + var exportFunctionsMap = ts.createMap(); + var noSubstitutionMap = ts.createMap(); var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; + var moduleInfo; + var exportFunction; + var contextObject; + var hoistedStatements; var enclosingBlockScopedContainer; - var currentParent; - var currentNode; + var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { return node; } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - ts.Debug.assert(!exportFunctionForFile); - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - addSystemModuleBody(statements, node, dependencyGroups); + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + enclosingBlockScopedContainer = node; + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + contextObject = ts.createUniqueName("context"); + var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ + ts.createParameter(undefined, undefined, undefined, exportFunction), + ts.createParameter(undefined, undefined, undefined, contextObject) + ], undefined, createSystemModuleBody(node, dependencyGroups)); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], undefined, ts.setEmitFlags(ts.createBlock(statements, undefined, true), 1)); - return updateSourceFile(node, [ + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], ~1 & ts.getEmitFlags(node)); - var _a; - } - function addSystemModuleBody(statements, node, dependencyGroups) { - startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, visitSourceElement); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - ts.addRange(statements, endLexicalEnvironment()); - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) - ]), true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction])) + ], node.statements)); + ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1); + if (noSubstitution) { + noSubstitutionMap[id] = noSubstitution; + noSubstitution = undefined; } - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_2 = externalImports; _i < externalImports_2.length; _i++) { - var externalImport = externalImports_2[_i]; - if (externalImport.kind === 237 && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - return addExportStarFunction(statements, undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var externalImport = externalImports_3[_b]; - if (externalImport.kind !== 237) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 231: - if (!entry.importClause) { - break; - } - case 230: - ts.Debug.assert(importVariableName !== undefined); - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 237: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); - } - else { - statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(parameterName)], undefined, ts.createBlock(statements, undefined, true))); - } - return ts.createArrayLiteral(setters, undefined, true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 231: - return visitImportDeclaration(node); - case 230: - return visitImportEqualsDeclaration(node); - case 237: - return visitExportDeclaration(node); - case 236: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 201: - return visitVariableStatement(node); - case 221: - return visitFunctionDeclaration(node); - case 222: - return visitClassDeclaration(node); - case 207: - return visitForStatement(node); - case 208: - return visitForInStatement(node); - case 209: - return visitForOfStatement(node); - case 205: - return visitDoStatement(node); - case 206: - return visitWhileStatement(node); - case 215: - return visitLabeledStatement(node); - case 213: - return visitWithStatement(node); - case 214: - return visitSwitchStatement(node); - case 228: - return visitCaseBlock(node); - case 249: - return visitCaseClause(node); - case 250: - return visitDefaultClause(node); - case 217: - return visitTryStatement(node); - case 252: - return visitCatchClause(node); - case 200: - return visitBlock(node); - case 203: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - return undefined; - } - return createExportStatement(ts.createLiteral("default"), node.expression); - } - function visitVariableStatement(node) { - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3) == 0) || - enclosingBlockScopedContainer.kind === 256; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - function transformVariable(node, isExported) { - hoistBindingElement(node, isExported); - if (!node.initializer) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - return ts.createAssignment(name, node.initializer); - } - else { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); - } - } - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1)) { - var name_41 = node.name || ts.getGeneratedNameForNode(node); - var isAsync = ts.hasModifier(node, 256); - var newNode = ts.createFunctionDeclaration(undefined, isAsync ? [ts.createNode(119)] : undefined, node.asteriskToken, name_41, undefined, node.parameters, undefined, node.body, node); - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512)) { - recordExportName(name_41); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 226 || originalNode.kind === 225) && ts.hasModifier(originalNode, 1)) { - var name_42 = getDeclarationName(originalNode); - if (originalNode.kind === 225) { - hoistVariableDeclaration(name_42); - } - return [ - node, - createExportStatement(name_42, name_42) - ]; - } - return node; - } - function visitClassDeclaration(node) { - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, node.heritageClauses, node.members, node)), node)); - if (ts.hasModifier(node, 1)) { - if (!ts.hasModifier(node, 512)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3) === 0; - } - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(194), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); - } - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1) { - return substituteExpression(node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70: - return substituteExpressionIdentifier(node); - case 188: - return substituteBinaryExpression(node); - case 186: - case 187: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128); - var left = node.left; - switch (left.kind) { - case 70: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 172: - case 171: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 70: - return isExportedBinding(node); - case 172: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 171: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 57 - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 70 - || kind === 172 - || kind === 171; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 187 || - (node.kind === 186 && (operator === 42 || operator === 43))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128); - var call = createExportExpression(operand, expr); - if (node.kind === 186) { - return call; - } - else { - return operator === 42 - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(m)], undefined, ts.createBlock([ - ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, undefined, [exports])) - ], undefined, true))); - return exportStarFunction; - } - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, undefined, [exportName, value]); - } - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + contextObject = undefined; + hoistedStatements = undefined; + enclosingBlockScopedContainer = undefined; + return ts.aggregateTransformFlags(updated); } function collectDependencyGroups(externalImports) { var groupIndices = ts.createMap(); @@ -44110,7 +44641,6 @@ var ts; if (ts.hasProperty(groupIndices, text)) { var groupIndex = groupIndices[text]; dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; } else { groupIndices[text] = dependencyGroups.length; @@ -44122,47 +44652,722 @@ var ts; } return dependencyGroups; } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; + function createSystemModuleBody(node, dependencyGroups) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) + ]))); + var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + ts.addRange(statements, hoistedStatements); + ts.addRange(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) + ]), true))); + var body = ts.createBlock(statements, undefined, true); + ts.setEmitFlags(body, 1); + return body; } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { + function addExportStarIfNeeded(statements) { + if (!moduleInfo.hasExportStarsToExportValues) { return; } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); + if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { + var externalImport = _a[_i]; + if (externalImport.kind === 240 && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + var exportStarFunction_1 = createExportStarFunction(undefined); + statements.push(exportStarFunction_1); + return exportStarFunction_1.name; } } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); + var exportedNames = []; + if (moduleInfo.exportedNames) { + for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) { + var exportedLocalName = _c[_b]; + if (exportedLocalName.text === "default") { + continue; + } + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + } + } + for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { + var externalImport = _e[_d]; + if (externalImport.kind !== 240) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + continue; + } + for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { + var element = _g[_f]; + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, undefined, ts.createObjectLiteral(exportedNames, undefined, true)) + ]))); + var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); + statements.push(exportStarFunction); + return exportStarFunction.name; + } + function createExportStarFunction(localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + } + return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([ + ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ])), + ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) + ], undefined, true)); + } + function createSettersArray(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 234: + if (!entry.importClause) { + break; + } + case 233: + ts.Debug.assert(importVariableName !== undefined); + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 240: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunction, undefined, [ts.createObjectLiteral(properties, undefined, true)]))); + } + else { + statements.push(ts.createStatement(ts.createCall(exportStarFunction, undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, parameterName)], undefined, ts.createBlock(statements, undefined, true))); + } + return ts.createArrayLiteral(setters, undefined, true); + } + function sourceElementVisitor(node) { + switch (node.kind) { + case 234: + return visitImportDeclaration(node); + case 233: + return visitImportEqualsDeclaration(node); + case 240: + return undefined; + case 239: + return visitExportAssignment(node); + default: + return nestedElementVisitor(node); } } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, true); + function visitImportDeclaration(node) { + var statements; + if (node.importClause) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, false); + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var expression = ts.visitNode(node.expression, destructuringVisitor, ts.isExpression); + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, true); + } + else { + return createExportStatement(ts.createIdentifier("default"), expression, true); + } + } + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1)) { + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + } + else { + hoistedStatements = ts.append(hoistedStatements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); + } + return undefined; + } + function visitClassDeclaration(node) { + var statements; + var name = ts.getLocalName(node); + hoistVariableDeclaration(name); + statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression(undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), node)), node)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + function visitVariableStatement(node) { + if (!shouldHoistVariableDeclarationList(node.declarationList)) { + return ts.visitNode(node, destructuringVisitor, ts.isStatement); + } + var expressions; + var isExportedDeclaration = ts.hasModifier(node, 1); + var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } + var statements; + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), node)); + } + if (isMarkedDeclaration) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + } + else { + statements = appendExportsOfVariableStatement(statements, node, false); + } + return ts.singleOrMany(statements); + } + function hoistBindingElement(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + hoistBindingElement(element); + } + } + } + else { + hoistVariableDeclaration(ts.getSynthesizedClone(node.name)); + } + } + function shouldHoistVariableDeclarationList(node) { + return (ts.getEmitFlags(node) & 16777216) === 0 + && (enclosingBlockScopedContainer.kind === 260 + || (ts.getOriginalNode(node).flags & 3) === 0); + } + function transformInitializedVariable(node, isExportedDeclaration) { + var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; + return ts.isBindingPattern(node.name) + ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); + } + function createExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, true); + } + function createNonExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, false); + } + function createVariableAssignment(name, value, location, isExportedDeclaration) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + return isExportedDeclaration + ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) + : preventSubstitution(ts.createAssignment(name, value, location)); + } + function visitMergeDeclarationMarker(node) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204) { + var id = ts.getOriginalNodeId(node); + var isExportedDeclaration = ts.hasModifier(node.original, 1); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + } + return node; + } + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432) !== 0; + } + function visitEndOfDeclarationMarker(node) { + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + function appendExportsOfImportDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + function appendExportsOfVariableStatement(statements, node, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.initializer || exportSelf) { + statements = appendExportsOfBindingElement(statements, decl, exportSelf); + } + } + return statements; + } + function appendExportsOfBindingElement(statements, decl, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element, exportSelf); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + var excludeName = void 0; + if (exportSelf) { + statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl)); + excludeName = decl.name.text; + } + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfHoistedDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var excludeName; + if (ts.hasModifier(decl, 1)) { + var exportName = ts.hasModifier(decl, 512) ? ts.createLiteral("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl)); + excludeName = exportName.text; + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + function appendExportsOfDeclaration(statements, decl, excludeName) { + if (moduleInfo.exportEquals) { + return statements; + } + var name = ts.getDeclarationName(decl); + var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; + if (exportSpecifier.name.text !== excludeName) { + statements = appendExportStatement(statements, exportSpecifier.name, name); + } + } + } + return statements; + } + function appendExportStatement(statements, exportName, expression, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, allowComments)); + return statements; + } + function createExportStatement(name, value, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value)); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152); + } + return statement; + } + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; + return ts.createCall(exportFunction, undefined, [exportName, value]); + } + function nestedElementVisitor(node) { + switch (node.kind) { + case 204: + return visitVariableStatement(node); + case 224: + return visitFunctionDeclaration(node); + case 225: + return visitClassDeclaration(node); + case 210: + return visitForStatement(node); + case 211: + return visitForInStatement(node); + case 212: + return visitForOfStatement(node); + case 208: + return visitDoStatement(node); + case 209: + return visitWhileStatement(node); + case 218: + return visitLabeledStatement(node); + case 216: + return visitWithStatement(node); + case 217: + return visitSwitchStatement(node); + case 231: + return visitCaseBlock(node); + case 252: + return visitCaseClause(node); + case 253: + return visitDefaultClause(node); + case 220: + return visitTryStatement(node); + case 255: + return visitCatchClause(node); + case 203: + return visitBlock(node); + case 293: + return visitMergeDeclarationMarker(node); + case 294: + return visitEndOfDeclarationMarker(node); + default: + return destructuringVisitor(node); + } + } + function visitForStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForInStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitForOfStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function shouldHoistForInitializer(node) { + return ts.isVariableDeclarationList(node) + && shouldHoistVariableDeclarationList(node); + } + function visitForInitializer(node) { + if (shouldHoistForInitializer(node)) { + var expressions = void 0; + for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + expressions = ts.append(expressions, transformInitializedVariable(variable, false)); + } + return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression(); + } + else { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + } + function visitDoStatement(node) { + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + } + function visitWhileStatement(node) { + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitLabeledStatement(node) { + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitWithStatement(node) { + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + } + function visitSwitchStatement(node) { + return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + } + function visitCaseBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitCaseClause(node) { + return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + } + function visitDefaultClause(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitTryStatement(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + function visitCatchClause(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function visitBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.visitEachChild(node, nestedElementVisitor, context); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + function destructuringVisitor(node) { + if (node.transformFlags & 16384 + && node.kind === 191) { + return visitDestructuringAssignment(node); + } + else if (node.transformFlags & 32768) { + return ts.visitEachChild(node, destructuringVisitor, context); + } + else { + return node; + } + } + function visitDestructuringAssignment(node) { + if (hasExportedReferenceInDestructuringTarget(node.left)) { + return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, destructuringVisitor); + } + return ts.visitEachChild(node, destructuringVisitor, context); + } + function hasExportedReferenceInDestructuringTarget(node) { + if (ts.isAssignmentExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.left); + } + else if (ts.isSpreadExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.expression); + } + else if (ts.isObjectLiteralExpression(node)) { + return ts.some(node.properties, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isArrayLiteralExpression(node)) { + return ts.some(node.elements, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.initializer); + } + else if (ts.isIdentifier(node)) { + var container = resolver.getReferencedExportContainer(node); + return container !== undefined && container.kind === 260; + } + else { + return false; + } + } + function modifierVisitor(node) { + switch (node.kind) { + case 83: + case 78: + return undefined; + } + return node; + } + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260) { + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; + if (noSubstitution) { + delete noSubstitutionMap[id]; + } + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (isSubstitutionPrevented(node)) { + return node; + } + if (emitContext === 1) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 70: + return substituteExpressionIdentifier(node); + case 191: + return substituteBinaryExpression(node); + case 189: + case 190: + return substituteUnaryExpression(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), node); + } + } + } + return node; + } + function substituteBinaryExpression(node) { + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + var expression = node; + for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + return expression; + } + } + return node; + } + function substituteUnaryExpression(node) { + if ((node.operator === 42 || node.operator === 43) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 + ? ts.createPrefix(node.operator, node.operand, node) + : node; + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 190) { + expression = node.operator === 42 + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); + } + return expression; + } + } + return node; + } + function getExports(name) { + var exportedNames; + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + var exportContainer = resolver.getReferencedExportContainer(name, false); + if (exportContainer && exportContainer.kind === 260) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); + } + } + return exportedNames; + } + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = ts.createMap(); + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; } } ts.transformSystemModule = transformSystemModule; @@ -44183,9 +45388,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 230: + case 233: return undefined; - case 236: + case 239: return visitExportAssignment(node); } return node; @@ -44212,10 +45417,12 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; transformers.push(ts.transformTypeScript); - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (jsx === 2) { transformers.push(ts.transformJsx); } + if (languageVersion < 5) { + transformers.push(ts.transformESNext); + } if (languageVersion < 4) { transformers.push(ts.transformES2017); } @@ -44226,6 +45433,7 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (languageVersion < 1) { transformers.push(ts.transformES5); } @@ -44235,7 +45443,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289); + var enabledSyntaxKindFeatures = new Array(295); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -44432,7 +45640,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 231); + ts.Debug.assert(aliasEmitInfo.node.kind === 234); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -44503,10 +45711,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219) { + if (declaration.kind === 222) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 || declaration.kind === 235 || declaration.kind === 232) { + else if (declaration.kind === 237 || declaration.kind === 238 || declaration.kind === 235) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -44517,7 +45725,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 231) { + if (moduleElementEmitInfo.node.kind === 234) { moduleElementEmitInfo.isVisible = true; } else { @@ -44525,12 +45733,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226) { + if (nodeToCheck.kind === 229) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -44643,43 +45851,47 @@ var ts; function emitType(type) { switch (type.kind) { case 118: - case 133: - case 131: - case 121: case 134: + case 132: + case 121: + case 135: case 104: - case 136: + case 137: case 94: - case 128: - case 166: + case 129: case 167: + case 170: return writeTextOfNode(currentText, type); - case 195: + case 198: return emitExpressionWithTypeArguments(type); - case 156: - return emitTypeReference(type); - case 159: - return emitTypeQuery(type); - case 161: - return emitArrayType(type); - case 162: - return emitTupleType(type); - case 163: - return emitUnionType(type); - case 164: - return emitIntersectionType(type); - case 165: - return emitParenType(type); case 157: - case 158: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 160: + return emitTypeQuery(type); + case 162: + return emitArrayType(type); + case 163: + return emitTupleType(type); + case 164: + return emitUnionType(type); + case 165: + return emitIntersectionType(type); + case 166: + return emitParenType(type); + case 168: + return emitTypeOperator(type); + case 169: + return emitPropertyAccessType(type); + case 158: + case 159: + return emitSignatureDeclarationWithJsDocComments(type); + case 161: return emitTypeLiteral(type); case 70: return emitEntityName(type); - case 140: + case 141: return emitEntityName(type); - case 155: + case 156: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -44687,22 +45899,22 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 140 ? entityName.left : entityName.expression; - var right = entityName.kind === 140 ? entityName.right : entityName.name; + var left = entityName.kind === 141 ? entityName.left : entityName.expression; + var right = entityName.kind === 141 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 230 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 233 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 173); + ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 176); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -44748,6 +45960,17 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitPropertyAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -44776,9 +45999,9 @@ var ts; var count = 0; while (true) { count++; - var name_43 = baseName + "_" + count; - if (!(name_43 in currentIdentifiers)) { - return name_43; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -44822,10 +46045,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 || - (node.parent.kind === 256 && isCurrentFileExternalModule)) { + else if (node.kind === 233 || + (node.parent.kind === 260 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 260) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -44834,7 +46057,7 @@ var ts; }); } else { - if (node.kind === 231) { + if (node.kind === 234) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -44852,30 +46075,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221: - return writeFunctionDeclaration(node); - case 201: - return writeVariableStatement(node); - case 223: - return writeInterfaceDeclaration(node); - case 222: - return writeClassDeclaration(node); case 224: - return writeTypeAliasDeclaration(node); - case 225: - return writeEnumDeclaration(node); + return writeFunctionDeclaration(node); + case 204: + return writeVariableStatement(node); case 226: + return writeInterfaceDeclaration(node); + case 225: + return writeClassDeclaration(node); + case 227: + return writeTypeAliasDeclaration(node); + case 228: + return writeEnumDeclaration(node); + case 229: return writeModuleDeclaration(node); - case 230: + case 233: return writeImportEqualsDeclaration(node); - case 231: + case 234: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 256) { + if (node.parent.kind === 260) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -44883,7 +46106,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 223 && !noDeclare) { + else if (node.kind !== 226 && !noDeclare) { write("declare "); } } @@ -44933,7 +46156,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 236) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -44956,7 +46179,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 233) { + if (node.importClause.namedBindings.kind === 236) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -44973,13 +46196,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 229; var moduleSpecifier; - if (parent.kind === 230) { + if (parent.kind === 233) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226) { + else if (parent.kind === 229) { moduleSpecifier = parent.name; } else { @@ -45047,7 +46270,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227) { + while (node.body && node.body.kind !== 230) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -45117,7 +46340,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 148 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 149 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -45127,15 +46350,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - (node.parent.parent && node.parent.parent.kind === 160)) { - ts.Debug.assert(node.parent.kind === 148 || - node.parent.kind === 147 || - node.parent.kind === 157 || + if (node.parent.kind === 158 || + node.parent.kind === 159 || + (node.parent.parent && node.parent.parent.kind === 161)) { + ts.Debug.assert(node.parent.kind === 149 || + node.parent.kind === 148 || node.parent.kind === 158 || - node.parent.kind === 152 || - node.parent.kind === 153); + node.parent.kind === 159 || + node.parent.kind === 153 || + node.parent.kind === 154); emitType(node.constraint); } else { @@ -45145,31 +46368,31 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 222: + case 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223: + case 226: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 153: + case 154: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 152: + case 153: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { 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 === 222) { + else if (node.parent.parent.kind === 225) { 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 221: + case 224: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -45206,7 +46429,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 222) { + if (node.parent.parent.kind === 225) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -45286,17 +46509,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 219 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 222 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 146 || node.kind === 145 || - (node.kind === 143 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 147 || node.kind === 146 || + (node.kind === 144 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 146 || node.kind === 145) && node.parent.kind === 160) { + if ((node.kind === 147 || node.kind === 146) && node.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -45309,14 +46532,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219) { + if (node.kind === 222) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 146 || node.kind === 145) { + else if (node.kind === 147 || node.kind === 146) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45324,7 +46547,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 === 222) { + else if (node.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45350,7 +46573,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 194) { + if (element.kind !== 197) { elements.push(element); } } @@ -45416,7 +46639,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 150 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 151 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -45429,7 +46652,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 150 + return accessor.kind === 151 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -45438,7 +46661,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 151) { + if (accessorWithTypeAnnotation.kind === 152) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -45484,17 +46707,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221) { + if (node.kind === 224) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 148 || node.kind === 149) { + else if (node.kind === 149 || node.kind === 150) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 221) { + if (node.kind === 224) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149) { + else if (node.kind === 150) { write("constructor"); } else { @@ -45514,15 +46737,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 154) { + if (node.kind === 155) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 153 || node.kind === 158) { + if (node.kind === 154 || node.kind === 159) { write("new "); } - else if (node.kind === 157) { + else if (node.kind === 158) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -45533,20 +46756,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 154) { + if (node.kind === 155) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 157 || node.kind === 158; - if (isFunctionTypeOrConstructorType || node.parent.kind === 160) { + var isFunctionTypeOrConstructorType = node.kind === 158 || node.kind === 159; + if (isFunctionTypeOrConstructorType || node.parent.kind === 161) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 149 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 150 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -45560,23 +46783,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 153: + case 154: 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 152: + case 153: 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 154: + case 155: 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 149: case 148: - case 147: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45584,7 +46807,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 === 222) { + else if (node.parent.kind === 225) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -45597,7 +46820,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221: + case 224: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -45629,9 +46852,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 157 || - node.parent.kind === 158 || - node.parent.parent.kind === 160) { + if (node.parent.kind === 158 || + node.parent.kind === 159 || + node.parent.parent.kind === 161) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -45647,22 +46870,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 149: + case 150: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? 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 153: + case 154: 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 152: + case 153: 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 149: case 148: - case 147: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -45670,7 +46893,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 === 222) { + else if (node.parent.parent.kind === 225) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45682,7 +46905,7 @@ 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 221: + case 224: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -45693,12 +46916,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 168) { + if (bindingPattern.kind === 171) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169) { + else if (bindingPattern.kind === 172) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -45709,10 +46932,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194) { + if (bindingElement.kind === 197) { write(" "); } - else if (bindingElement.kind === 170) { + else if (bindingElement.kind === 173) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -45734,39 +46957,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221: - case 226: - case 230: - case 223: - case 222: case 224: + case 229: + case 233: + case 226: case 225: + case 227: + case 228: return emitModuleElement(node, isModuleElementVisible(node)); - case 201: + case 204: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231: + case 234: return emitModuleElement(node, !node.importClause); - case 237: + case 240: return emitExportDeclaration(node); + case 150: case 149: case 148: - case 147: return writeFunctionDeclaration(node); - case 153: - case 152: case 154: + case 153: + case 155: return emitSignatureDeclarationWithJsDocComments(node); - case 150: case 151: + case 152: return emitAccessorDeclaration(node); + case 147: case 146: - case 145: return emitPropertyDeclaration(node); - case 255: + case 259: return emitEnumMemberDeclaration(node); - case 236: + case 239: return emitExportAssignment(node); - case 256: + case 260: return emitSourceFile(node); } } @@ -45983,7 +47206,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 512) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -45996,7 +47219,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 + if (node.kind !== 291 && (emitFlags & 1024) === 0 && end >= 0) { emitPos(end); @@ -46140,7 +47363,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287; + var isEmittedNode = node.kind !== 291; var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; if (!skipLeadingComments) { @@ -46154,7 +47377,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 220) { + if (node.kind === 223) { declarationListContainerEnd = end; } } @@ -46361,6 +47584,7 @@ var ts; var brackets = createBracketsMap(); var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; + var restHelper = "\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))\n t[p] = s[p];\n return t;\n};"; var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; @@ -46393,6 +47617,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -46526,7 +47751,7 @@ var ts; function pipelineEmitInSourceFileContext(node) { var kind = node.kind; switch (kind) { - case 256: + case 260: return emitSourceFile(node); } } @@ -46564,7 +47789,6 @@ var ts; case 123: case 124: case 125: - case 126: case 127: case 128: case 129: @@ -46578,182 +47802,189 @@ var ts; case 137: case 138: case 139: + case 140: writeTokenText(kind); return; - case 140: - return emitQualifiedName(node); case 141: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 142: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 143: - return emitParameter(node); + return emitTypeParameter(node); case 144: - return emitDecorator(node); + return emitParameter(node); case 145: - return emitPropertySignature(node); + return emitDecorator(node); case 146: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 147: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 148: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 149: - return emitConstructor(node); + return emitMethodDeclaration(node); case 150: + return emitConstructor(node); case 151: - return emitAccessorDeclaration(node); case 152: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 153: - return emitConstructSignature(node); + return emitCallSignature(node); case 154: - return emitIndexSignature(node); + return emitConstructSignature(node); case 155: - return emitTypePredicate(node); + return emitIndexSignature(node); case 156: - return emitTypeReference(node); + return emitTypePredicate(node); case 157: - return emitFunctionType(node); + return emitTypeReference(node); case 158: - return emitConstructorType(node); + return emitFunctionType(node); case 159: - return emitTypeQuery(node); + return emitConstructorType(node); case 160: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 161: - return emitArrayType(node); + return emitTypeLiteral(node); case 162: - return emitTupleType(node); + return emitArrayType(node); case 163: - return emitUnionType(node); + return emitTupleType(node); case 164: - return emitIntersectionType(node); + return emitUnionType(node); case 165: - return emitParenthesizedType(node); - case 195: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 166: - return emitThisType(); - case 167: - return emitLiteralType(node); - case 168: - return emitObjectBindingPattern(node); - case 169: - return emitArrayBindingPattern(node); - case 170: - return emitBindingElement(node); + return emitParenthesizedType(node); case 198: - return emitTemplateSpan(node); - case 199: - return emitSemicolonClassElement(); - case 200: - return emitBlock(node); + return emitExpressionWithTypeArguments(node); + case 167: + return emitThisType(); + case 168: + return emitTypeOperator(node); + case 169: + return emitPropertyAccessType(node); + case 170: + return emitLiteralType(node); + case 171: + return emitObjectBindingPattern(node); + case 172: + return emitArrayBindingPattern(node); + case 173: + return emitBindingElement(node); case 201: - return emitVariableStatement(node); + return emitTemplateSpan(node); case 202: - return emitEmptyStatement(); + return emitSemicolonClassElement(); case 203: - return emitExpressionStatement(node); + return emitBlock(node); case 204: - return emitIfStatement(node); + return emitVariableStatement(node); case 205: - return emitDoStatement(node); + return emitEmptyStatement(); case 206: - return emitWhileStatement(node); + return emitExpressionStatement(node); case 207: - return emitForStatement(node); + return emitIfStatement(node); case 208: - return emitForInStatement(node); + return emitDoStatement(node); case 209: - return emitForOfStatement(node); + return emitWhileStatement(node); case 210: - return emitContinueStatement(node); + return emitForStatement(node); case 211: - return emitBreakStatement(node); + return emitForInStatement(node); case 212: - return emitReturnStatement(node); + return emitForOfStatement(node); case 213: - return emitWithStatement(node); + return emitContinueStatement(node); case 214: - return emitSwitchStatement(node); + return emitBreakStatement(node); case 215: - return emitLabeledStatement(node); + return emitReturnStatement(node); case 216: - return emitThrowStatement(node); + return emitWithStatement(node); case 217: - return emitTryStatement(node); + return emitSwitchStatement(node); case 218: - return emitDebuggerStatement(node); + return emitLabeledStatement(node); case 219: - return emitVariableDeclaration(node); + return emitThrowStatement(node); case 220: - return emitVariableDeclarationList(node); + return emitTryStatement(node); case 221: - return emitFunctionDeclaration(node); + return emitDebuggerStatement(node); case 222: - return emitClassDeclaration(node); + return emitVariableDeclaration(node); case 223: - return emitInterfaceDeclaration(node); + return emitVariableDeclarationList(node); case 224: - return emitTypeAliasDeclaration(node); + return emitFunctionDeclaration(node); case 225: - return emitEnumDeclaration(node); + return emitClassDeclaration(node); case 226: - return emitModuleDeclaration(node); + return emitInterfaceDeclaration(node); case 227: - return emitModuleBlock(node); + return emitTypeAliasDeclaration(node); case 228: - return emitCaseBlock(node); + return emitEnumDeclaration(node); + case 229: + return emitModuleDeclaration(node); case 230: - return emitImportEqualsDeclaration(node); + return emitModuleBlock(node); case 231: - return emitImportDeclaration(node); - case 232: - return emitImportClause(node); + return emitCaseBlock(node); case 233: - return emitNamespaceImport(node); + return emitImportEqualsDeclaration(node); case 234: - return emitNamedImports(node); + return emitImportDeclaration(node); case 235: - return emitImportSpecifier(node); + return emitImportClause(node); case 236: - return emitExportAssignment(node); + return emitNamespaceImport(node); case 237: - return emitExportDeclaration(node); + return emitNamedImports(node); case 238: - return emitNamedExports(node); + return emitImportSpecifier(node); case 239: - return emitExportSpecifier(node); + return emitExportAssignment(node); case 240: - return; + return emitExportDeclaration(node); case 241: + return emitNamedExports(node); + case 242: + return emitExportSpecifier(node); + case 243: + return; + case 244: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 244: - return emitJsxOpeningElement(node); - case 245: - return emitJsxClosingElement(node); - case 246: - return emitJsxAttribute(node); case 247: - return emitJsxSpreadAttribute(node); + return emitJsxOpeningElement(node); case 248: - return emitJsxExpression(node); + return emitJsxClosingElement(node); case 249: - return emitCaseClause(node); + return emitJsxAttribute(node); case 250: - return emitDefaultClause(node); + return emitJsxSpreadAttribute(node); case 251: - return emitHeritageClause(node); + return emitJsxExpression(node); case 252: - return emitCatchClause(node); + return emitCaseClause(node); case 253: - return emitPropertyAssignment(node); + return emitDefaultClause(node); case 254: - return emitShorthandPropertyAssignment(node); + return emitHeritageClause(node); case 255: + return emitCatchClause(node); + case 256: + return emitPropertyAssignment(node); + case 257: + return emitShorthandPropertyAssignment(node); + case 258: + return emitSpreadAssignment(node); + case 259: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -46778,63 +48009,63 @@ var ts; case 98: writeTokenText(kind); return; - case 171: - return emitArrayLiteralExpression(node); - case 172: - return emitObjectLiteralExpression(node); - case 173: - return emitPropertyAccessExpression(node); case 174: - return emitElementAccessExpression(node); + return emitArrayLiteralExpression(node); case 175: - return emitCallExpression(node); + return emitObjectLiteralExpression(node); case 176: - return emitNewExpression(node); + return emitPropertyAccessExpression(node); case 177: - return emitTaggedTemplateExpression(node); + return emitElementAccessExpression(node); case 178: - return emitTypeAssertionExpression(node); + return emitCallExpression(node); case 179: - return emitParenthesizedExpression(node); + return emitNewExpression(node); case 180: - return emitFunctionExpression(node); + return emitTaggedTemplateExpression(node); case 181: - return emitArrowFunction(node); + return emitTypeAssertionExpression(node); case 182: - return emitDeleteExpression(node); + return emitParenthesizedExpression(node); case 183: - return emitTypeOfExpression(node); + return emitFunctionExpression(node); case 184: - return emitVoidExpression(node); + return emitArrowFunction(node); case 185: - return emitAwaitExpression(node); + return emitDeleteExpression(node); case 186: - return emitPrefixUnaryExpression(node); + return emitTypeOfExpression(node); case 187: - return emitPostfixUnaryExpression(node); + return emitVoidExpression(node); case 188: - return emitBinaryExpression(node); + return emitAwaitExpression(node); case 189: - return emitConditionalExpression(node); + return emitPrefixUnaryExpression(node); case 190: - return emitTemplateExpression(node); + return emitPostfixUnaryExpression(node); case 191: - return emitYieldExpression(node); + return emitBinaryExpression(node); case 192: - return emitSpreadElementExpression(node); + return emitConditionalExpression(node); case 193: - return emitClassExpression(node); + return emitTemplateExpression(node); case 194: - return; + return emitYieldExpression(node); + case 195: + return emitSpreadExpression(node); case 196: - return emitAsExpression(node); + return emitClassExpression(node); case 197: + return; + case 199: + return emitAsExpression(node); + case 200: return emitNonNullExpression(node); - case 242: + case 245: return emitJsxElement(node); - case 243: + case 246: return emitJsxSelfClosingElement(node); - case 288: + case 292: return emitPartiallyEmittedExpression(node); } } @@ -46938,7 +48169,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 150 ? "get " : "set "); + write(node.kind === 151 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -47023,6 +48254,17 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitPropertyAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -47186,7 +48428,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 186 + return operand.kind === 189 && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); } @@ -47230,7 +48472,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -47298,7 +48540,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 204) { + if (node.elseStatement.kind === 207) { write(" "); emit(node.elseStatement); } @@ -47360,7 +48602,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220) { + if (node.kind === 223) { emit(node); } else { @@ -47589,7 +48831,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226) { + while (body.kind === 229) { write("."); emit(body.name); body = body.body; @@ -47808,6 +49050,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } function emitEnumMember(node) { emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); @@ -47877,10 +49125,17 @@ var ts; extendsEmitted = true; helpersEmitted = true; } - if (compilerOptions.jsx !== 1 && !assignEmitted && (node.flags & 16384)) { + if ((languageVersion < 5 || currentSourceFile.scriptKind === 2 || currentSourceFile.scriptKind === 4) && + compilerOptions.jsx !== 1 && + !assignEmitted && + node.flags & 16384) { writeLines(assignHelper); assignEmitted = true; } + if (languageVersion < 5 && !restEmitted && node.flags & 32768) { + writeLines(restHelper); + restEmitted = true; + } if (!decorateEmitted && node.flags & 2048) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -48203,7 +49458,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 && ts.nodeIsSynthesized(node)) { + while (node.kind === 182 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -48260,21 +49515,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_44 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_44)) { + var name_40 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_44; + return name_40; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_45 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_45)) { - return name_45; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -48312,17 +49567,17 @@ var ts; switch (node.kind) { case 70: return makeUniqueName(getTextOfNode(node)); - case 226: - case 225: + case 229: + case 228: return generateNameForModuleOrEnum(node); - case 231: - case 237: + case 234: + case 240: return generateNameForImportOrExportDeclaration(node); - case 221: - case 222: - case 236: + case 224: + case 225: + case 239: return generateNameForExportDefault(); - case 193: + case 196: return generateNameForClassExpression(); default: return makeTempVariableName(0); @@ -48395,7 +49650,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.2"; + ts.version = "2.1.3"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -48610,11 +49865,11 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_46 = names_2[_i]; - var result = name_46 in cache - ? cache[name_46] - : cache[name_46] = loader(name_46, containingFile); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_42 = names_1[_i]; + var result = name_42 in cache + ? cache[name_42] + : cache[name_42] = loader(name_42, containingFile); resolutions.push(result); } return resolutions; @@ -48628,7 +49883,7 @@ var ts; var classifiableNames; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; var currentNodeModulesDepth = 0; var modulesWithElidedImports = ts.createMap(); var sourceFilesFoundSearchingNodeModules = ts.createMap(); @@ -48641,7 +49896,14 @@ var ts; var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); var resolveModuleNamesWorker; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { + if (!resolved || resolved.extension !== undefined) { + return resolved; + } + var withExtension = ts.clone(resolved); + withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); + return withExtension; + }); }; } else { var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; @@ -48703,6 +49965,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -48734,6 +49997,79 @@ var ts; } return classifiableNames; } + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + if (!oldProgramState && !file.ambientModuleNames.length) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var unknownModuleNames; + var result; + var predictedToResolveToAmbientModuleMarker = {}; + for (var i = 0; i < moduleNames.length; i++) { + var moduleName = moduleNames[i]; + var isKnownToResolveToAmbientModule = false; + if (ts.contains(file.ambientModuleNames, moduleName)) { + isKnownToResolveToAmbientModule = 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); + } + } + else { + isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + } + if (isKnownToResolveToAmbientModule) { + if (!unknownModuleNames) { + result = new Array(moduleNames.length); + unknownModuleNames = moduleNames.slice(0, i); + } + result[i] = predictedToResolveToAmbientModuleMarker; + } + else if (unknownModuleNames) { + unknownModuleNames.push(moduleName); + } + } + if (!unknownModuleNames) { + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var resolutions = unknownModuleNames.length + ? resolveModuleNamesWorker(unknownModuleNames, containingFile) + : emptyArray; + var j = 0; + for (var i = 0; i < result.length; i++) { + if (result[i] == predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } + else { + result[i] = resolutions[j]; + j++; + } + } + ts.Debug.assert(j === resolutions.length); + return result; + function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { + if (!oldProgramState) { + return false; + } + var resolutionToFile = ts.getResolvedModule(oldProgramState.file, moduleName); + if (resolutionToFile) { + return false; + } + var ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + if (!(ambientModule && ambientModule.declarations)) { + return false; + } + var firstUnmodifiedFile = ts.forEach(ambientModule.declarations, function (d) { + var f = ts.getSourceFileOfNode(d); + return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && f; + }); + if (!firstUnmodifiedFile) { + return false; + } + if (ts.isTraceEnabled(options, host)) { + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + } + return true; + } + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return false; @@ -48780,40 +50116,44 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { return false; } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else { newSourceFile = oldSourceFile; } newSourceFiles.push(newSourceFile); } + var modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths: modifiedFilePaths }); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } for (var i = 0, len = newSourceFiles.length; i < len; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + for (var _d = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _d < modifiedSourceFiles_2.length; _d++) { + var modifiedFile = modifiedSourceFiles_2[_d]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); oldProgram.structureIsReused = true; @@ -48829,11 +50169,14 @@ var ts; getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, }; } + function isSourceFileFromExternalLibrary(file) { + return sourceFilesFoundSearchingNodeModules[file.path]; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -48910,6 +50253,12 @@ var ts; } } function getSyntacticDiagnosticsForFile(sourceFile) { + if (ts.isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); + } return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -48929,175 +50278,163 @@ var ts; var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; + var parent = sourceFile; walk(sourceFile); return diagnostics; function walk(node) { - if (!node) { - return false; - } - switch (node.kind) { - case 230: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 236: - if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 222: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251: - var heritageClause = node; - if (heritageClause.token === 107) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 223: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 226: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 224: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 148: + switch (parent.kind) { + case 144: case 147: + if (parent.questionToken === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return; + } case 149: + case 148: case 150: case 151: - case 180: - case 221: + case 152: + case 183: + case 224: + case 184: + case 224: + case 222: + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } + } + switch (node.kind) { + case 233: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 239: + if (node.isExportEquals) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 254: + var heritageClause = node; + if (heritageClause.token === 107) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return; + } + break; + case 226: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 229: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 227: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 228: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; case 181: - case 221: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + var typeAssertionExpression = node; + diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return; + } + var prevParent = parent; + parent = node; + ts.forEachChild(node, walk, walkArray); + parent = prevParent; + } + function walkArray(nodes) { + if (parent.decorators === nodes && !options.experimentalDecorators) { + 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_to_remove_this_warning)); + } + switch (parent.kind) { + case 225: + case 149: + case 148: + case 150: + case 151: + case 152: + case 183: + case 224: + case 184: + case 224: + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + case 204: + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 204); } break; - case 201: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 219: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 175: - case 176: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 143: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 146: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + case 147: + if (nodes === parent.modifiers) { + for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 114) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } - } - if (checkTypeAnnotation(node.type)) { - return true; + return; } break; - case 225: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 178: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; case 144: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + if (nodes === parent.modifiers) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return; } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 113: - case 111: - case 112: - case 129: - case 123: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - case 114: - case 83: - case 75: - case 78: - case 116: + break; + case 178: + case 179: + case 198: + if (nodes === parent.typeArguments) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return; } + break; + } + for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { + var node = nodes_4[_b]; + walk(node); + } + } + function checkModifiers(modifiers, isConstValid) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 75: + if (isConstValid) { + continue; + } + case 113: + case 111: + case 112: + case 130: + case 123: + case 116: + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + break; + case 114: + case 83: + case 78: } } - return false; + } + function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) { + var start = nodes.pos; + return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2); + } + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } }); } @@ -49121,9 +50458,6 @@ var ts; ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } @@ -49142,14 +50476,18 @@ var ts; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); var isExternalModuleFile = ts.isExternalModule(file); + var isDtsFile = ts.isDeclarationFile(file); var imports; var moduleAugmentations; + var ambientModules; if (options.importHelpers && (options.isolatedModules || isExternalModuleFile) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9); + var externalHelpersModuleReference = ts.createSynthesizedNode(9); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; + var importDecl = ts.createSynthesizedNode(234); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -49161,12 +50499,13 @@ var ts; } file.imports = imports || emptyArray; file.moduleAugmentations = moduleAugmentations || emptyArray; + file.ambientModuleNames = ambientModules || emptyArray; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 231: - case 230: - case 237: + case 234: + case 233: + case 240: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -49178,13 +50517,16 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226: + case 229: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { + if (isDtsFile) { + (ambientModules || (ambientModules = [])).push(moduleName.text); + } var body = node.body; if (body) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { @@ -49208,7 +50550,7 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; - if (hasExtension(fileName)) { + if (ts.hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; @@ -49269,7 +50611,7 @@ var ts; processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + if (currentNodeModulesDepth < maxNodeModuleJsDepth) { modulesWithElidedImports[file_1.path] = false; processImportedModules(file_1); } @@ -49378,23 +50720,31 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); + var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); + if (!resolution) { + continue; + } + var isFromNodeModulesSearch = resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; + var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); + var pos = ts.skipTrivia(file.text, file.imports[i].pos); + findSourceFile(resolvedFileName, path, false, file, pos, file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -49404,7 +50754,6 @@ var ts; else { file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -49558,7 +50907,15 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + if (options.jsxFactory) { + if (options.reactNamespace) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory")); + } + if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory)); + } + } + else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } if (!options.noEmit && !options.suppressOutputPathCheck) { @@ -49573,17 +50930,12 @@ var ts; if (emitFileName) { var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); if (filesByName.contains(emitFilePath)) { - if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) { - blockEmittingOfFile(emitFileName); - } - else { - var chain_1; - if (!options.configFilePath) { - chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); - } - chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); - blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); + var chain_1; + if (!options.configFilePath) { + chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); } + chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); } if (emitFilesSeen.contains(emitFilePath)) { blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName)); @@ -49596,12 +50948,31 @@ var ts; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - if (diag) { - programDiagnostics.add(diag); - } + programDiagnostics.add(diag); } } ts.createProgram = createProgram; + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: + return undefined; + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); + } + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; + } + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + } + } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); var ts; (function (ts) { @@ -49640,12 +51011,13 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + var IndentStyle; (function (IndentStyle) { IndentStyle[IndentStyle["None"] = 0] = "None"; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; + })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -49669,8 +51041,8 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -49681,8 +51053,7 @@ var ts; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; + })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { ScriptElementKind.unknown = ""; @@ -49761,37 +51132,37 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.scanner = ts.createScanner(4, true); + ts.scanner = ts.createScanner(5, true); ts.emptyArray = []; function getMeaningFromDeclaration(node) { switch (node.kind) { - case 143: - case 219: - case 170: - case 146: - case 145: - case 253: - case 254: - case 255: - case 148: + case 144: + case 222: + case 173: case 147: + case 146: + case 256: + case 257: + case 259: case 149: + case 148: case 150: case 151: - case 221: - case 180: - case 181: - case 252: - return 1; - case 142: - case 223: + case 152: case 224: - case 160: - return 2; - case 222: - case 225: - return 1 | 2; + case 183: + case 184: + case 255: + return 1; + case 143: case 226: + case 227: + case 161: + return 2; + case 225: + case 228: + return 1 | 2; + case 229: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -49801,21 +51172,21 @@ var ts; else { return 4; } - case 234: - case 235: - case 230: - case 231: - case 236: case 237: + case 238: + case 233: + case 234: + case 239: + case 240: return 1 | 2 | 4; - case 256: + case 260: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236) { + if (node.parent.kind === 239) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -49837,15 +51208,15 @@ var ts; ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 140 && + if (node.parent.kind === 141 && node.parent.right === node && - node.parent.parent.kind === 230) { + node.parent.parent.kind === 233) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 140) { + while (node.parent.kind === 141) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -49856,27 +51227,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 140) { - while (root.parent && root.parent.kind === 140) { + if (root.parent.kind === 141) { + while (root.parent && root.parent.kind === 141) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 156 && !isLastClause; + return root.parent.kind === 157 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 173) { - while (root.parent && root.parent.kind === 173) { + if (root.parent.kind === 176) { + while (root.parent && root.parent.kind === 176) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 && root.parent.parent.kind === 251) { + if (!isLastClause && root.parent.kind === 198 && root.parent.parent.kind === 254) { var decl = root.parent.parent.parent; - return (decl.kind === 222 && root.parent.parent.token === 107) || - (decl.kind === 223 && root.parent.parent.token === 84); + return (decl.kind === 225 && root.parent.parent.token === 107) || + (decl.kind === 226 && root.parent.parent.token === 84); } return false; } @@ -49884,17 +51255,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 156 || - (node.parent.kind === 195 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 157 || + (node.parent.kind === 198 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 166; + node.kind === 167; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175); + return isCallOrNewExpressionTarget(node, 178); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176); + return isCallOrNewExpressionTarget(node, 179); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -49907,7 +51278,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 218 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -49917,13 +51288,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 && - (node.parent.kind === 211 || node.parent.kind === 210) && + (node.parent.kind === 214 || node.parent.kind === 213) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 && - node.parent.kind === 215 && + node.parent.kind === 218 && node.parent.label === node; } function isLabelName(node) { @@ -49931,15 +51302,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 140 && node.parent.right === node; + return node.parent.kind === 141 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 173 && node.parent.name === node; + return node && node.parent && node.parent.kind === 176 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 && node.parent.name === node; + return node.parent.kind === 229 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -49950,19 +51321,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 146: - case 145: - case 253: - case 255: - case 148: case 147: - case 150: + case 146: + case 256: + case 259: + case 149: + case 148: case 151: - case 226: + case 152: + case 229: return node.parent.name === node; - case 174: + case 177: return node.parent.argumentExpression === node; - case 141: + case 142: return true; } } @@ -50006,17 +51377,17 @@ var ts; return undefined; } switch (node.kind) { - case 256: + case 260: + case 149: case 148: - case 147: - case 221: - case 180: - case 150: + case 224: + case 183: case 151: - case 222: - case 223: + case 152: case 225: case 226: + case 228: + case 229: return node; } } @@ -50024,46 +51395,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256: + case 260: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226: + case 229: return ts.ScriptElementKind.moduleElement; - case 222: - case 193: + case 225: + case 196: return ts.ScriptElementKind.classElement; - case 223: return ts.ScriptElementKind.interfaceElement; - case 224: return ts.ScriptElementKind.typeElement; - case 225: return ts.ScriptElementKind.enumElement; - case 219: + case 226: return ts.ScriptElementKind.interfaceElement; + case 227: return ts.ScriptElementKind.typeElement; + case 228: return ts.ScriptElementKind.enumElement; + case 222: return getKindOfVariableDeclaration(node); - case 170: + case 173: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: return ts.ScriptElementKind.functionElement; - case 150: return ts.ScriptElementKind.memberGetAccessorElement; - case 151: return ts.ScriptElementKind.memberSetAccessorElement; + case 151: return ts.ScriptElementKind.memberGetAccessorElement; + case 152: return ts.ScriptElementKind.memberSetAccessorElement; + case 149: case 148: - case 147: return ts.ScriptElementKind.memberFunctionElement; + case 147: case 146: - case 145: return ts.ScriptElementKind.memberVariableElement; - case 154: return ts.ScriptElementKind.indexSignatureElement; - case 153: return ts.ScriptElementKind.constructSignatureElement; - case 152: return ts.ScriptElementKind.callSignatureElement; - case 149: return ts.ScriptElementKind.constructorImplementationElement; - case 142: return ts.ScriptElementKind.typeParameterElement; - case 255: return ts.ScriptElementKind.enumMemberElement; - case 143: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 230: - case 235: - case 232: - case 239: + case 155: return ts.ScriptElementKind.indexSignatureElement; + case 154: return ts.ScriptElementKind.constructSignatureElement; + case 153: return ts.ScriptElementKind.callSignatureElement; + case 150: return ts.ScriptElementKind.constructorImplementationElement; + case 143: return ts.ScriptElementKind.typeParameterElement; + case 259: return ts.ScriptElementKind.enumMemberElement; + case 144: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 233: + case 238: + case 235: + case 242: + case 236: return ts.ScriptElementKind.alias; - case 279: + case 283: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -50078,7 +51449,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 ? node.parent : node; + var searchNode = node.parent.kind === 170 ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32) { return type; @@ -50091,7 +51462,7 @@ var ts; case 98: return true; case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 143; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 144; default: return false; } @@ -50135,41 +51506,41 @@ var ts; return false; } switch (n.kind) { - case 222: - case 223: case 225: - case 172: - case 168: - case 160: - case 200: - case 227: + case 226: case 228: - case 234: - case 238: + case 175: + case 171: + case 161: + case 203: + case 230: + case 231: + case 237: + case 241: return nodeEndsWith(n, 17, sourceFile); - case 252: + case 255: return isCompletedNode(n.block, sourceFile); - case 176: + case 179: if (!n.arguments) { return true; } - case 175: - case 179: - case 165: + case 178: + case 182: + case 166: return nodeEndsWith(n, 19, sourceFile); - case 157: case 158: + case 159: return isCompletedNode(n.type, sourceFile); - case 149: case 150: case 151: - case 221: - case 180: - case 148: - case 147: - case 153: case 152: - case 181: + case 224: + case 183: + case 149: + case 148: + case 154: + case 153: + case 184: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -50177,65 +51548,65 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 226: + case 229: return n.body && isCompletedNode(n.body, sourceFile); - case 204: + case 207: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203: + case 206: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24); - case 171: - case 169: case 174: - case 141: - case 162: + case 172: + case 177: + case 142: + case 163: return nodeEndsWith(n, 21, sourceFile); - case 154: + case 155: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21, sourceFile); - case 249: - case 250: + case 252: + case 253: return false; - case 207: - case 208: + case 210: + case 211: + case 212: case 209: - case 206: return isCompletedNode(n.statement, sourceFile); - case 205: + case 208: var hasWhileKeyword = findChildOfKind(n, 105, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 159: + case 160: return isCompletedNode(n.exprName, sourceFile); - case 183: - case 182: - case 184: - case 191: - case 192: + case 186: + case 185: + case 187: + case 194: + case 195: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177: + case 180: return isCompletedNode(n.template, sourceFile); - case 190: + case 193: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198: + case 201: return ts.nodeIsPresent(n.literal); - case 237: - case 231: + case 240: + case 234: return ts.nodeIsPresent(n.moduleSpecifier); - case 186: - return isCompletedNode(n.operand, sourceFile); - case 188: - return isCompletedNode(n.right, sourceFile); case 189: + return isCompletedNode(n.operand, sourceFile); + case 191: + return isCompletedNode(n.right, sourceFile); + case 192: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -50278,7 +51649,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 286 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 290 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -50413,7 +51784,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256); + ts.Debug.assert(startNode !== undefined || n.kind === 260); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -50458,15 +51829,15 @@ var ts; if (token.kind === 26 && token.parent.kind === 10) { return true; } + if (token.kind === 26 && token.parent.kind === 251) { + return true; + } + if (token && token.kind === 17 && token.parent.kind === 251) { + return true; + } if (token.kind === 26 && token.parent.kind === 248) { return true; } - if (token && token.kind === 17 && token.parent.kind === 248) { - return true; - } - if (token.kind === 26 && token.parent.kind === 245) { - return true; - } return false; } ts.isInsideJsxElementOrAttribute = isInsideJsxElementOrAttribute; @@ -50555,17 +51926,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 || node.kind === 175) { + if (node.kind === 157 || node.kind === 178) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 || node.kind === 223) { + if (ts.isFunctionLike(node) || node.kind === 225 || node.kind === 226) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 139; + return n.kind >= 0 && n.kind <= 140; } ts.isToken = isToken; function isWord(kind) { @@ -50624,18 +51995,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 || - node.kind === 172) { - if (node.parent.kind === 188 && + if (node.kind === 174 || + node.kind === 175) { + if (node.parent.kind === 191 && node.parent.left === node && node.parent.operatorToken.kind === 57) { return true; } - if (node.parent.kind === 209 && + if (node.parent.kind === 212 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 256 ? node.parent.parent : node.parent)) { return true; } } @@ -50666,7 +52037,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -50841,7 +52212,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 141) { + location.parent.kind === 142) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); @@ -50851,7 +52222,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 || location.parent.kind === 239) && + (location.parent.kind === 238 || location.parent.kind === 242) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -50956,89 +52327,89 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201: + case 204: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219: - case 146: - case 145: - return spanInVariableDeclaration(node); - case 143: - return spanInParameterDeclaration(node); - case 221: - case 148: + case 222: case 147: - case 150: - case 151: + case 146: + return spanInVariableDeclaration(node); + case 144: + return spanInParameterDeclaration(node); + case 224: case 149: - case 180: - case 181: + case 148: + case 151: + case 152: + case 150: + case 183: + case 184: return spanInFunctionDeclaration(node); - case 200: + case 203: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 227: - return spanInBlock(node); - case 252: - return spanInBlock(node.block); - case 203: - return textSpan(node.expression); - case 212: - return textSpan(node.getChildAt(0), node.expression); - case 206: - return textSpanEndingAtNextToken(node, node.expression); - case 205: - return spanInNode(node.statement); - case 218: - return textSpan(node.getChildAt(0)); - case 204: - return textSpanEndingAtNextToken(node, node.expression); - case 215: - return spanInNode(node.statement); - case 211: - case 210: - return textSpan(node.getChildAt(0), node.label); - case 207: - return spanInForStatement(node); - case 208: - return textSpanEndingAtNextToken(node, node.expression); - case 209: - return spanInInitializerOfForLike(node); - case 214: - return textSpanEndingAtNextToken(node, node.expression); - case 249: - case 250: - return spanInNode(node.statements[0]); - case 217: - return spanInBlock(node.tryBlock); - case 216: - return textSpan(node, node.expression); - case 236: - return textSpan(node, node.expression); case 230: + return spanInBlock(node); + case 255: + return spanInBlock(node.block); + case 206: + return textSpan(node.expression); + case 215: + return textSpan(node.getChildAt(0), node.expression); + case 209: + return textSpanEndingAtNextToken(node, node.expression); + case 208: + return spanInNode(node.statement); + case 221: + return textSpan(node.getChildAt(0)); + case 207: + return textSpanEndingAtNextToken(node, node.expression); + case 218: + return spanInNode(node.statement); + case 214: + case 213: + return textSpan(node.getChildAt(0), node.label); + case 210: + return spanInForStatement(node); + case 211: + return textSpanEndingAtNextToken(node, node.expression); + case 212: + return spanInInitializerOfForLike(node); + case 217: + return textSpanEndingAtNextToken(node, node.expression); + case 252: + case 253: + return spanInNode(node.statements[0]); + case 220: + return spanInBlock(node.tryBlock); + case 219: + return textSpan(node, node.expression); + case 239: + return textSpan(node, node.expression); + case 233: return textSpan(node, node.moduleReference); - case 231: + case 234: return textSpan(node, node.moduleSpecifier); - case 237: + case 240: return textSpan(node, node.moduleSpecifier); - case 226: + case 229: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 222: case 225: - case 255: - case 170: + case 228: + case 259: + case 173: return textSpan(node); - case 213: + case 216: return spanInNode(node.statement); - case 144: + case 145: return spanInNodeArray(node.parent.decorators); - case 168: - case 169: + case 171: + case 172: return spanInBindingPattern(node); - case 223: - case 224: + case 226: + case 227: return undefined; case 24: case 1: @@ -51066,20 +52437,20 @@ var ts; case 73: case 86: return spanInNextNode(node); - case 139: + case 140: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 70 || - node.kind == 192 || - node.kind === 253 || - node.kind === 254) && + node.kind == 195 || + node.kind === 256 || + node.kind === 257) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188) { + if (node.kind === 191) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); @@ -51094,38 +52465,38 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205: + case 208: return spanInPreviousNode(node); - case 144: + case 145: return spanInNode(node.parent); - case 207: - case 209: + case 210: + case 212: return textSpan(node); - case 188: + case 191: if (node.parent.operatorToken.kind === 25) { return textSpan(node); } break; - case 181: + case 184: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 253 && + if (node.parent.kind === 256 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 178 && node.parent.type === node) { + if (node.parent.kind === 181 && node.parent.type === node) { return spanInNextNode(node.parent.type); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { return spanInPreviousNode(node); } - if ((node.parent.kind === 219 || - node.parent.kind === 143)) { + if ((node.parent.kind === 222 || + node.parent.kind === 144)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -51133,7 +52504,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188) { + if (node.parent.kind === 191) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -51154,7 +52525,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 208) { + if (variableDeclaration.parent.parent.kind === 211) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -51162,7 +52533,7 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 209) { + variableDeclaration.parent.parent.kind === 212) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -51194,7 +52565,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 222 && functionDeclaration.kind !== 149); + (functionDeclaration.parent.kind === 225 && functionDeclaration.kind !== 150); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -51214,22 +52585,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226: + case 229: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 206: - case 204: - case 208: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 207: case 209: + case 207: + case 211: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 210: + case 212: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 220) { + if (forLikeStatement.initializer.kind === 223) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -51251,62 +52622,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 197 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 170) { + if (bindingPattern.parent.kind === 173) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 169 && node.kind !== 168); - var elements = node.kind === 171 ? + ts.Debug.assert(node.kind !== 172 && node.kind !== 171); + var elements = node.kind === 174 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 197 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 188 ? node.parent : node); + return textSpan(node.parent.kind === 191 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225: + case 228: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 222: + case 225: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 228: + case 231: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227: + case 230: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } + case 228: case 225: - case 222: return textSpan(node); - case 200: + case 203: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 252: + case 255: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228: + case 231: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168: + case 171: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51319,7 +52690,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169: + case 172: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -51331,33 +52702,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 || - node.parent.kind === 175 || - node.parent.kind === 176) { + if (node.parent.kind === 208 || + node.parent.kind === 178 || + node.parent.kind === 179) { return spanInPreviousNode(node); } - if (node.parent.kind === 179) { + if (node.parent.kind === 182) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 180: - case 221: - case 181: - case 148: - case 147: - case 150: - case 151: + case 183: + case 224: + case 184: case 149: - case 206: - case 205: - case 207: + case 148: + case 151: + case 152: + case 150: case 209: - case 175: - case 176: + case 208: + case 210: + case 212: + case 178: case 179: + case 182: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -51365,26 +52736,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 || - node.parent.kind === 143) { + node.parent.kind === 256 || + node.parent.kind === 144) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178) { + if (node.parent.kind === 181) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205) { + if (node.parent.kind === 208) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209) { + if (node.parent.kind === 212) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -51397,7 +52768,7 @@ var ts; var ts; (function (ts) { function createClassifier() { - var scanner = ts.createScanner(4, false); + var scanner = ts.createScanner(5, false); var noRegexTable = []; noRegexTable[70] = true; noRegexTable[9] = true; @@ -51415,7 +52786,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 || - keyword2 === 132 || + keyword2 === 133 || keyword2 === 122 || keyword2 === 114) { return true; @@ -51531,10 +52902,10 @@ var ts; angleBracketStack--; } else if (token === 118 || - token === 133 || - token === 131 || + token === 134 || + token === 132 || token === 121 || - token === 134) { + token === 135) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { token = 70; } @@ -51689,7 +53060,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 && token <= 139; + return token >= 71 && token <= 140; } function classFromKind(token) { if (isKeyword(token)) { @@ -51735,10 +53106,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { + case 229: + case 225: case 226: - case 222: - case 223: - case 221: + case 224: cancellationToken.throwIfCancellationRequested(); } } @@ -51782,7 +53153,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 && + return declaration.kind === 229 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -51854,8 +53225,8 @@ var ts; function getEncodedSyntacticClassifications(cancellationToken, sourceFile, span) { var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(4, false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(5, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(5, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -51923,16 +53294,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 275: + case 279: processJSDocParameterTag(tag); break; - case 278: + case 282: processJSDocTemplateTag(tag); break; - case 277: + case 281: processElement(tag.typeExpression); break; - case 276: + case 280: processElement(tag.typeExpression); break; } @@ -52013,22 +53384,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244: + case 247: if (token.parent.tagName === token) { return 19; } break; - case 245: + case 248: if (token.parent.tagName === token) { return 20; } break; - case 243: + case 246: if (token.parent.tagName === token) { return 21; } break; - case 246: + case 249: if (token.parent.name === token) { return 22; } @@ -52048,17 +53419,17 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { if (tokenKind === 57) { - if (token.parent.kind === 219 || - token.parent.kind === 146 || - token.parent.kind === 143 || - token.parent.kind === 246) { + if (token.parent.kind === 222 || + token.parent.kind === 147 || + token.parent.kind === 144 || + token.parent.kind === 249) { return 5; } } - if (token.parent.kind === 188 || - token.parent.kind === 186 || - token.parent.kind === 187 || - token.parent.kind === 189) { + if (token.parent.kind === 191 || + token.parent.kind === 189 || + token.parent.kind === 190 || + token.parent.kind === 192) { return 5; } } @@ -52068,7 +53439,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 246 ? 24 : 6; + return token.parent.kind === 249 ? 24 : 6; } else if (tokenKind === 11) { return 6; @@ -52082,32 +53453,32 @@ var ts; else if (tokenKind === 70) { if (token) { switch (token.parent.kind) { - case 222: + case 225: if (token.parent.name === token) { return 11; } return; - case 142: + case 143: if (token.parent.name === token) { return 15; } return; - case 223: + case 226: if (token.parent.name === token) { return 13; } return; - case 225: + case 228: if (token.parent.name === token) { return 12; } return; - case 226: + case 229: if (token.parent.name === token) { return 14; } return; - case 143: + case 144: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -52162,7 +53533,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 && - location.parent && location.parent.kind === 245) { + location.parent && location.parent.kind === 248) { var tagName = location.parent.parent.openingElement.tagName; entries.push({ name: tagName.text, @@ -52184,13 +53555,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_47 in nameTable) { - if (nameTable[name_47] === position) { + for (var name_43 in nameTable) { + if (nameTable[name_43] === position) { continue; } - if (!uniqueNames[name_47]) { - uniqueNames[name_47] = name_47; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_47), compilerOptions.target, true); + if (!uniqueNames[name_43]) { + uniqueNames[name_43] = name_43; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_43), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -52240,15 +53611,15 @@ var ts; if (!node || node.kind !== 9) { return undefined; } - if (node.parent.kind === 253 && - node.parent.parent.kind === 172 && + if (node.parent.kind === 256 && + node.parent.parent.kind === 175 && node.parent.name === node) { return getStringLiteralCompletionEntriesFromPropertyAssignment(node.parent); } else if (ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 231 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 234 || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { return getStringLiteralCompletionEntriesFromModuleNames(node); } else { @@ -52577,8 +53948,8 @@ var ts; } catch (e) { } if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; + for (var _b = 0, typeRoots_3 = typeRoots; _b < typeRoots_3.length; _b++) { + var root = typeRoots_3[_b]; getCompletionEntriesFromDirectories(host, root, span, result); } } @@ -52612,11 +53983,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_15 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_15) { break; } - currentDir = parent_16; + currentDir = parent_15; } else { break; @@ -52748,9 +54119,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277: - case 275: - case 276: + case 281: + case 279: + case 280: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -52785,13 +54156,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_16 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_17.kind === 173) { + if (parent_16.kind === 176) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140) { + else if (parent_16.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -52804,7 +54175,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 && contextToken.parent.kind === 245) { + else if (kind === 40 && contextToken.parent.kind === 248) { isStartingCloseTag = true; location = contextToken; } @@ -52849,7 +54220,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 140 || node.kind === 173) { + if (node.kind === 70 || node.kind === 141 || node.kind === 176) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -52895,7 +54266,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243) || (jsxContainer.kind === 244)) { + if ((jsxContainer.kind === 246) || (jsxContainer.kind === 247)) { attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes); @@ -52916,9 +54287,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 || - scopeNode.kind === 190 || - scopeNode.kind === 248 || + scopeNode.kind === 260 || + scopeNode.kind === 193 || + scopeNode.kind === 251 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -52946,11 +54317,11 @@ var ts; return true; } if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 244) { + if (contextToken.parent.kind === 247) { return true; } - if (contextToken.parent.kind === 245 || contextToken.parent.kind === 243) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242; + if (contextToken.parent.kind === 248 || contextToken.parent.kind === 246) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 245; } } return false; @@ -52960,40 +54331,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 - || containingNodeKind === 171 - || containingNodeKind === 188 - || containingNodeKind === 157; - case 18: - return containingNodeKind === 175 - || containingNodeKind === 149 - || containingNodeKind === 176 + return containingNodeKind === 178 + || containingNodeKind === 150 || containingNodeKind === 179 - || containingNodeKind === 165; + || containingNodeKind === 174 + || containingNodeKind === 191 + || containingNodeKind === 158; + case 18: + return containingNodeKind === 178 + || containingNodeKind === 150 + || containingNodeKind === 179 + || containingNodeKind === 182 + || containingNodeKind === 166; case 20: - return containingNodeKind === 171 - || containingNodeKind === 154 - || containingNodeKind === 141; - case 126: + return containingNodeKind === 174 + || containingNodeKind === 155 + || containingNodeKind === 142; case 127: + case 128: return true; case 22: - return containingNodeKind === 226; + return containingNodeKind === 229; case 16: - return containingNodeKind === 222; + return containingNodeKind === 225; case 57: - return containingNodeKind === 219 - || containingNodeKind === 188; + return containingNodeKind === 222 + || containingNodeKind === 191; case 13: - return containingNodeKind === 190; + return containingNodeKind === 193; case 14: - return containingNodeKind === 198; + return containingNodeKind === 201; case 113: case 111: case 112: - return containingNodeKind === 146; + return containingNodeKind === 147; } switch (previousToken.getText()) { case "public": @@ -53024,22 +54395,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172) { + if (objectLikeContainer.kind === 175) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168) { + else if (objectLikeContainer.kind === 171) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 143) { + if (!canGetType && rootDeclaration.kind === 144) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 148 || rootDeclaration.parent.kind === 151) { + else if (rootDeclaration.parent.kind === 149 || rootDeclaration.parent.kind === 152) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -53065,9 +54436,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 ? - 231 : - 237; + var declarationKind = namedImportsOrExports.kind === 237 ? + 234 : + 240; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -53088,9 +54459,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 172 || parent_18.kind === 168)) { - return parent_18; + var parent_17 = contextToken.parent; + if (parent_17 && (parent_17.kind === 175 || parent_17.kind === 171)) { + return parent_17; } break; } @@ -53103,8 +54474,8 @@ var ts; case 16: case 25: switch (contextToken.parent.kind) { - case 234: - case 238: + case 237: + case 241: return contextToken.parent; } } @@ -53113,34 +54484,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_18 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: - case 246: - case 247: - if (parent_19 && (parent_19.kind === 243 || parent_19.kind === 244)) { - return parent_19; + case 249: + case 250: + if (parent_18 && (parent_18.kind === 246 || parent_18.kind === 247)) { + return parent_18; } - else if (parent_19.kind === 246) { - return parent_19.parent; + else if (parent_18.kind === 249) { + return parent_18.parent; } break; case 9: - if (parent_19 && ((parent_19.kind === 246) || (parent_19.kind === 247))) { - return parent_19.parent; + if (parent_18 && ((parent_18.kind === 249) || (parent_18.kind === 250))) { + return parent_18.parent; } break; case 17: - if (parent_19 && - parent_19.kind === 248 && - parent_19.parent && - (parent_19.parent.kind === 246)) { - return parent_19.parent.parent; + if (parent_18 && + parent_18.kind === 251 && + parent_18.parent && + (parent_18.parent.kind === 249)) { + return parent_18.parent.parent; } - if (parent_19 && parent_19.kind === 247) { - return parent_19.parent; + if (parent_18 && parent_18.kind === 250) { + return parent_18.parent; } break; } @@ -53149,16 +54520,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180: - case 181: - case 221: + case 183: + case 184: + case 224: + case 149: case 148: - case 147: - case 150: case 151: case 152: case 153: case 154: + case 155: return true; } return false; @@ -53167,66 +54538,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25: - return containingNodeKind === 219 || - containingNodeKind === 220 || - containingNodeKind === 201 || - containingNodeKind === 225 || - isFunction(containingNodeKind) || - containingNodeKind === 222 || - containingNodeKind === 193 || + return containingNodeKind === 222 || containingNodeKind === 223 || - containingNodeKind === 169 || - containingNodeKind === 224; + containingNodeKind === 204 || + containingNodeKind === 228 || + isFunction(containingNodeKind) || + containingNodeKind === 225 || + containingNodeKind === 196 || + containingNodeKind === 226 || + containingNodeKind === 172 || + containingNodeKind === 227; case 22: - return containingNodeKind === 169; + return containingNodeKind === 172; case 55: - return containingNodeKind === 170; + return containingNodeKind === 173; case 20: - return containingNodeKind === 169; + return containingNodeKind === 172; case 18: - return containingNodeKind === 252 || + return containingNodeKind === 255 || isFunction(containingNodeKind); case 16: - return containingNodeKind === 225 || - containingNodeKind === 223 || - containingNodeKind === 160; + return containingNodeKind === 228 || + containingNodeKind === 226 || + containingNodeKind === 161; case 24: - return containingNodeKind === 145 && + return containingNodeKind === 146 && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 223 || - contextToken.parent.parent.kind === 160); + (contextToken.parent.parent.kind === 226 || + contextToken.parent.parent.kind === 161); case 26: - return containingNodeKind === 222 || - containingNodeKind === 193 || - containingNodeKind === 223 || - containingNodeKind === 224 || + return containingNodeKind === 225 || + containingNodeKind === 196 || + containingNodeKind === 226 || + containingNodeKind === 227 || isFunction(containingNodeKind); case 114: - return containingNodeKind === 146; + return containingNodeKind === 147; case 23: - return containingNodeKind === 143 || + return containingNodeKind === 144 || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 169); + contextToken.parent.parent.kind === 172); case 113: case 111: case 112: - return containingNodeKind === 143; + return containingNodeKind === 144; case 117: - return containingNodeKind === 235 || - containingNodeKind === 239 || - containingNodeKind === 233; + return containingNodeKind === 238 || + containingNodeKind === 242 || + containingNodeKind === 236; case 74: case 82: case 108: case 88: case 103: case 124: - case 132: + case 133: case 90: case 109: case 75: case 115: - case 135: + case 136: return true; } switch (contextToken.getText()) { @@ -53263,8 +54634,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_48 = element.propertyName || element.name; - existingImportsOrExports[name_48.text] = true; + var name_44 = element.propertyName || element.name; + existingImportsOrExports[name_44.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -53278,17 +54649,19 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 253 && - m.kind !== 254 && - m.kind !== 170 && - m.kind !== 148) { + if (m.kind !== 256 && + m.kind !== 257 && + m.kind !== 173 && + m.kind !== 149 && + m.kind !== 151 && + m.kind !== 152) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 170 && m.propertyName) { + if (m.kind === 173 && m.propertyName) { if (m.propertyName.kind === 70) { existingName = m.propertyName.text; } @@ -53307,7 +54680,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246) { + if (attr.kind === 249) { seenNames[attr.name.text] = true; } } @@ -53340,7 +54713,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 139; i++) { + for (var i = 71; i <= 140; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -53404,7 +54777,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 70 || node.kind === 98 || - node.kind === 166 || + node.kind === 167 || node.kind === 96 || node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { @@ -53456,75 +54829,75 @@ var ts; switch (node.kind) { case 89: case 81: - if (hasKind(node.parent, 204)) { + if (hasKind(node.parent, 207)) { return getIfElseOccurrences(node.parent); } break; case 95: - if (hasKind(node.parent, 212)) { + if (hasKind(node.parent, 215)) { return getReturnOccurrences(node.parent); } break; case 99: - if (hasKind(node.parent, 216)) { + if (hasKind(node.parent, 219)) { return getThrowOccurrences(node.parent); } break; case 73: - if (hasKind(parent(parent(node)), 217)) { + if (hasKind(parent(parent(node)), 220)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101: case 86: - if (hasKind(parent(node), 217)) { + if (hasKind(parent(node), 220)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97: - if (hasKind(node.parent, 214)) { + if (hasKind(node.parent, 217)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72: case 78: - if (hasKind(parent(parent(parent(node))), 214)) { + if (hasKind(parent(parent(parent(node))), 217)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71: case 76: - if (hasKind(node.parent, 211) || hasKind(node.parent, 210)) { + if (hasKind(node.parent, 214) || hasKind(node.parent, 213)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87: - if (hasKind(node.parent, 207) || - hasKind(node.parent, 208) || - hasKind(node.parent, 209)) { + if (hasKind(node.parent, 210) || + hasKind(node.parent, 211) || + hasKind(node.parent, 212)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105: case 80: - if (hasKind(node.parent, 206) || hasKind(node.parent, 205)) { + if (hasKind(node.parent, 209) || hasKind(node.parent, 208)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 122: - if (hasKind(node.parent, 149)) { + if (hasKind(node.parent, 150)) { return getConstructorOccurrences(node.parent); } break; case 124: - case 132: - if (hasKind(node.parent, 150) || hasKind(node.parent, 151)) { + case 133: + if (hasKind(node.parent, 151) || hasKind(node.parent, 152)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 201)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 204)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -53536,10 +54909,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216) { + if (node.kind === 219) { statementAccumulator.push(node); } - else if (node.kind === 217) { + else if (node.kind === 220) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -53559,17 +54932,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256) { - return parent_20; + var parent_19 = child.parent; + if (ts.isFunctionBlock(parent_19) || parent_19.kind === 260) { + return parent_19; } - if (parent_20.kind === 217) { - var tryStatement = parent_20; + if (parent_19.kind === 220) { + var tryStatement = parent_19; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_19; } return undefined; } @@ -53578,7 +54951,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 || node.kind === 210) { + if (node.kind === 214 || node.kind === 213) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -53593,15 +54966,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 214: - if (statement.kind === 210) { + case 217: + if (statement.kind === 213) { continue; } - case 207: - case 208: + case 210: + case 211: + case 212: case 209: - case 206: - case 205: + case 208: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -53618,24 +54991,24 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 222 || - container.kind === 193 || - (declaration.kind === 143 && hasKind(container, 149)))) { + if (!(container.kind === 225 || + container.kind === 196 || + (declaration.kind === 144 && hasKind(container, 150)))) { return undefined; } } else if (modifier === 114) { - if (!(container.kind === 222 || container.kind === 193)) { + if (!(container.kind === 225 || container.kind === 196)) { return undefined; } } else if (modifier === 83 || modifier === 123) { - if (!(container.kind === 227 || container.kind === 256)) { + if (!(container.kind === 230 || container.kind === 260)) { return undefined; } } else if (modifier === 116) { - if (!(container.kind === 222 || declaration.kind === 222)) { + if (!(container.kind === 225 || declaration.kind === 225)) { return undefined; } } @@ -53646,8 +55019,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227: - case 256: + case 230: + case 260: if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } @@ -53655,15 +55028,15 @@ var ts; nodes = container.statements; } break; - case 149: + case 150: nodes = container.parameters.concat(container.parent.members); break; - case 222: - case 193: + case 225: + case 196: nodes = container.members; if (modifierFlag & 28) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 149 && member; + return member.kind === 150 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -53716,13 +55089,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 150); tryPushAccessorKeyword(accessorDeclaration.symbol, 151); + tryPushAccessorKeyword(accessorDeclaration.symbol, 152); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 132); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124, 133); }); } } } @@ -53739,7 +55112,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87, 105, 80)) { - if (loopNode.kind === 205) { + if (loopNode.kind === 208) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105)) { @@ -53760,13 +55133,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207: + case 210: + case 211: + case 212: case 208: case 209: - case 205: - case 206: return getLoopBreakContinueOccurrences(owner); - case 214: + case 217: return getSwitchCaseDefaultOccurrences(owner); } } @@ -53816,7 +55189,7 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 200))) { + if (!(func && hasKind(func.body, 203))) { return undefined; } var keywords = []; @@ -53830,7 +55203,7 @@ var ts; } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 204) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 207) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { @@ -53841,7 +55214,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204)) { + if (!hasKind(ifStatement.elseStatement, 207)) { break; } ifStatement = ifStatement.elseStatement; @@ -53876,7 +55249,7 @@ var ts; } DocumentHighlights.getDocumentHighlights = getDocumentHighlights; function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 215; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 218; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -54080,16 +55453,16 @@ var ts; } function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608) { - var defaultImport = ts.getDeclarationOfKind(symbol, 232); + var defaultImport = ts.getDeclarationOfKind(symbol, 235); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 || - declaration.kind === 239) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 238 || + declaration.kind === 242) ? declaration : undefined; }); if (importOrExportSpecifier && (!importOrExportSpecifier.propertyName || importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 235 ? + return importOrExportSpecifier.kind === 238 ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -54104,14 +55477,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 173); return bindingElement && - bindingElement.parent.kind === 168 && + bindingElement.parent.kind === 171 && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170); + var bindingElement = ts.getDeclarationOfKind(symbol, 173); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -54127,13 +55500,13 @@ var ts; } function getSymbolScope(symbol) { var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 || valueDeclaration.kind === 193)) { + if (valueDeclaration && (valueDeclaration.kind === 183 || valueDeclaration.kind === 196)) { return valueDeclaration; } if (symbol.flags & (4 | 8192)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 222); + return ts.getAncestor(privateDeclaration, 225); } } if (symbol.flags & 8388608) { @@ -54157,7 +55530,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 256 && !ts.isExternalModule(container)) { + if (container.kind === 260 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -54179,8 +55552,8 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -54324,14 +55697,14 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149); + ts.Debug.assert(decl.kind === 150); var ctrKeyword = decl.getChildAt(0); ts.Debug.assert(ctrKeyword.kind === 122); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 148) { + if (decl && decl.kind === 149) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 98, function (thisKeyword) { @@ -54353,7 +55726,7 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149); + ts.Debug.assert(decl.kind === 150); var body = decl.body; if (body) { forEachDescendantOfKind(body, 96, function (node) { @@ -54394,7 +55767,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70) { - if (refNode.parent.kind === 254) { + if (refNode.parent.kind === 257) { getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -54404,24 +55777,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_21 = containingTypeReference.parent; - if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); + var parent_20 = containingTypeReference.parent; + if (ts.isVariableLike(parent_20) && parent_20.type === containingTypeReference && parent_20.initializer && isImplementationExpression(parent_20.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_20.initializer)); } - else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 200) { - ts.forEachReturnStatement(parent_21.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_20) && parent_20.type === containingTypeReference && parent_20.body) { + if (parent_20.body.kind === 203) { + ts.forEachReturnStatement(parent_20.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_21.body)) { - maybeAdd(getReferenceEntryFromNode(parent_21.body)); + else if (isImplementationExpression(parent_20.body)) { + maybeAdd(getReferenceEntryFromNode(parent_20.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_20) && isImplementationExpression(parent_20.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_20.expression)); } } } @@ -54456,26 +55829,26 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 - && node.parent.kind === 251 + if (node.kind === 198 + && node.parent.kind === 254 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 || node.kind === 173) { + else if (node.kind === 70 || node.kind === 176) { return getContainingClassIfInHeritageClause(node.parent); } } return undefined; } function isImplementationExpression(node) { - if (node.kind === 179) { + if (node.kind === 182) { return isImplementationExpression(node.expression); } - return node.kind === 181 || - node.kind === 180 || - node.kind === 172 || - node.kind === 193 || - node.kind === 171; + return node.kind === 184 || + node.kind === 183 || + node.kind === 175 || + node.kind === 196 || + node.kind === 174; } function explicitlyInheritsFrom(child, parent, cachedResults) { var parentIsInterface = parent.getFlags() & 64; @@ -54504,7 +55877,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223) { + else if (declaration.kind === 226) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -54531,13 +55904,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 146: - case 145: - case 148: case 147: + case 146: case 149: + case 148: case 150: case 151: + case 152: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -54565,32 +55938,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 149: case 148: - case 147: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 147: case 146: - case 145: - case 149: case 150: case 151: + case 152: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 256: + case 260: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 221: - case 180: + case 224: + case 183: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256) { + if (searchSpaceNode.kind === 260) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -54624,26 +55997,26 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 180: - case 221: + case 183: + case 224: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; + case 149: case 148: - case 147: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 193: - case 222: + case 196: + case 225: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 256: - if (container.kind === 256 && !ts.isExternalModule(container)) { + case 260: + if (container.kind === 260 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -54692,7 +56065,7 @@ var ts; function populateSearchSymbolSet(symbol, location) { var result = [symbol]; var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 257) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -54711,7 +56084,7 @@ var ts; result.push(shorthandValueSymbol); } } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -54742,7 +56115,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223) { + else if (declaration.kind === 226) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -54805,7 +56178,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 141) { + if (node.name.kind === 142) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression.kind)) { return nameExpression.text; @@ -54874,7 +56247,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219) { + else if (node.kind === 222) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2); } @@ -54884,18 +56257,18 @@ var ts; } else { switch (node.kind) { - case 222: - case 193: case 225: - case 226: + case 196: + case 228: + case 229: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 201) { - ts.Debug.assert(node.parent.kind === 220); + if (node.parent && node.parent.parent && node.parent.parent.kind === 204) { + ts.Debug.assert(node.parent.kind === 223); return node.parent.parent; } } @@ -54933,10 +56306,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 || parent.kind === 186) { + if (parent.kind === 190 || parent.kind === 189) { return true; } - else if (parent.kind === 188 && parent.left === node) { + else if (parent.kind === 191 && parent.left === node) { var operator = parent.operatorToken.kind; return 57 <= operator && operator <= 69; } @@ -54955,7 +56328,7 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 141) { + if (node.parent.kind === 142) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } case 70: @@ -54965,11 +56338,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253: - case 254: - case 148: - case 150: + case 256: + case 257: + case 149: case 151: + case 152: return true; } return false; @@ -55028,11 +56401,11 @@ var ts; var declaration = symbol.declarations[0]; if (node.kind === 70 && (node.parent === declaration || - (declaration.kind === 235 && declaration.parent && declaration.parent.kind === 234))) { + (declaration.kind === 238 && declaration.parent && declaration.parent.kind === 237))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 254) { + if (node.parent.kind === 257) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -55109,8 +56482,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 149) || - (!selectConstructors && (d.kind === 221 || d.kind === 148 || d.kind === 147))) { + if ((selectConstructors && d.kind === 150) || + (!selectConstructors && (d.kind === 224 || d.kind === 149 || d.kind === 148))) { declarations.push(d); if (d.body) definition = d; @@ -55186,7 +56559,7 @@ var ts; var GoToImplementation; (function (GoToImplementation) { function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 254) { + if (node.parent.kind === 257) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -55311,16 +56684,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221: - case 148: + case 224: case 149: - case 222: - case 201: + case 150: + case 225: + case 204: break findOwner; - case 256: + case 260: return undefined; - case 226: - if (commentOwner.parent.kind === 226) { + case 229: + if (commentOwner.parent.kind === 229) { return undefined; } break findOwner; @@ -55354,7 +56727,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201) { + if (commentOwner.kind === 204) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -55364,17 +56737,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179) { + while (rightHandSide.kind === 182) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180: - case 181: + case 183: + case 184: return rightHandSide.parameters; - case 193: + case 196: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149) { + if (member.kind === 150) { return member.parameters; } } @@ -55397,10 +56770,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_49 in nameToDeclarations) { - var declarations = nameToDeclarations[name_49]; + for (var name_45 in nameToDeclarations) { + var declarations = nameToDeclarations[name_45]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_45); if (!matches) { continue; } @@ -55411,21 +56784,21 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_49); + matches = patternMatcher.getMatches(containers, name_45); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_45, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } }); rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 232 || decl.kind === 235 || decl.kind === 230) { + if (decl.kind === 235 || decl.kind === 238 || decl.kind === 233) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -55466,7 +56839,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 141) { + else if (declaration.name.kind === 142) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -55483,7 +56856,7 @@ var ts; } return true; } - if (expression.kind === 173) { + if (expression.kind === 176) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -55494,7 +56867,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 141) { + if (declaration.name.kind === 142) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -55626,7 +56999,7 @@ var ts; return; } switch (node.kind) { - case 149: + case 150: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -55636,28 +57009,28 @@ var ts; } } break; - case 148: - case 150: + case 149: case 151: - case 147: + case 152: + case 148: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 147: case 146: - case 145: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 232: + case 235: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233) { + if (namedBindings.kind === 236) { addLeafNode(namedBindings); } else { @@ -55668,12 +57041,12 @@ var ts; } } break; - case 170: - case 219: + case 173: + case 222: var decl = node; - var name_50 = decl.name; - if (ts.isBindingPattern(name_50)) { - addChildrenRecursively(name_50); + var name_46 = decl.name; + if (ts.isBindingPattern(name_46)) { + addChildrenRecursively(name_46); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -55682,12 +57055,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: addNodeWithRecursiveChild(node, node.body); break; - case 225: + case 228: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -55697,9 +57070,9 @@ var ts; } endNode(); break; - case 222: - case 193: - case 223: + case 225: + case 196: + case 226: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -55707,21 +57080,21 @@ var ts; } endNode(); break; - case 226: + case 229: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239: - case 230: - case 154: - case 152: + case 242: + case 233: + case 155: case 153: - case 224: + case 154: + case 227: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279) { + if (tag.kind === 283) { addLeafNode(tag); } }); @@ -55769,12 +57142,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 226 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 229 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 226) { + if (a.body.kind !== 229) { return true; } return areSameModule(a.body, b.body); @@ -55825,7 +57198,7 @@ var ts; return a.length - b.length; }; function tryGetName(node) { - if (node.kind === 226) { + if (node.kind === 229) { return getModuleName(node); } var decl = node; @@ -55833,18 +57206,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180: - case 181: - case 193: + case 183: + case 184: + case 196: return getFunctionOrClassName(node); - case 279: + case 283: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226) { + if (node.kind === 229) { return getModuleName(node); } var name = node.name; @@ -55855,29 +57228,29 @@ var ts; } } switch (node.kind) { - case 256: + case 260: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 181: - case 221: - case 180: - case 222: - case 193: + case 184: + case 224: + case 183: + case 225: + case 196: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 149: + case 150: return "constructor"; - case 153: - return "new()"; - case 152: - return "()"; case 154: + return "new()"; + case 153: + return "()"; + case 155: return "[]"; - case 279: + case 283: return getJSDocTypedefTagName(node); default: return ""; @@ -55889,7 +57262,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201) { + if (parentNode && parentNode.kind === 204) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70) { @@ -55917,24 +57290,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222: - case 193: case 225: - case 223: + case 196: + case 228: case 226: - case 256: - case 224: - case 279: + case 229: + case 260: + case 227: + case 283: return true; - case 149: - case 148: case 150: + case 149: case 151: - case 219: + case 152: + case 222: return hasSomeImportantChild(item); - case 181: - case 221: - case 180: + case 184: + case 224: + case 183: return isTopLevelFunctionDeclaration(item); default: return false; @@ -55944,10 +57317,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227: - case 256: - case 148: + case 230: + case 260: case 149: + case 150: return true; default: return hasSomeImportantChild(item); @@ -55956,7 +57329,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 && childKind !== 170; + return childKind !== 222 && childKind !== 173; }); } } @@ -56011,20 +57384,20 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 229) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 226 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 229 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 141; + return !member.name || member.name.kind === 142; } function getNodeSpan(node) { - return node.kind === 256 + return node.kind === 260 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -56032,14 +57405,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 219) { + else if (node.parent.kind === 222) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 && + else if (node.parent.kind === 191 && node.parent.operatorToken.kind === 57) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 && node.parent.name) { + else if (node.parent.kind === 256 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -56050,7 +57423,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 || node.kind === 181 || node.kind === 193; + return node.kind === 183 || node.kind === 184 || node.kind === 196; } var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); @@ -56123,7 +57496,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181; + return ts.isFunctionBlock(node) && node.parent.kind !== 184; } var depth = 0; var maxDepth = 20; @@ -56135,26 +57508,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200: + case 203: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_21 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_22.kind === 205 || - parent_22.kind === 208 || - parent_22.kind === 209 || - parent_22.kind === 207 || - parent_22.kind === 204 || - parent_22.kind === 206 || - parent_22.kind === 213 || - parent_22.kind === 252) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + if (parent_21.kind === 208 || + parent_21.kind === 211 || + parent_21.kind === 212 || + parent_21.kind === 210 || + parent_21.kind === 207 || + parent_21.kind === 209 || + parent_21.kind === 216 || + parent_21.kind === 255) { + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217) { - var tryStatement = parent_22; + if (parent_21.kind === 220) { + var tryStatement = parent_21; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -56174,23 +57547,23 @@ var ts; }); break; } - case 227: { + case 230: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 222: - case 223: case 225: - case 172: - case 228: { + case 226: + case 228: + case 175: + case 231: { var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171: + case 174: var openBracket = ts.findChildOfKind(n, 20, sourceFile); var closeBracket = ts.findChildOfKind(n, 21, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -56208,13 +57581,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var PatternMatchKind; (function (PatternMatchKind) { PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; + })(PatternMatchKind = ts.PatternMatchKind || (ts.PatternMatchKind = {})); function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { return { kind: kind, @@ -56435,7 +57808,7 @@ var ts; if (ch >= 65 && ch <= 90) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 5)) { return false; } var str = String.fromCharCode(ch); @@ -56445,7 +57818,7 @@ var ts; if (ch >= 97 && ch <= 122) { return true; } - if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 4)) { + if (ch < 127 || !ts.isUnicodeIdentifierStart(ch, 5)) { return false; } var str = String.fromCharCode(ch); @@ -56681,7 +58054,7 @@ var ts; var token = ts.scanner.getToken(); if (token === 123) { token = nextToken(); - if (token === 126) { + if (token === 127) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -56702,7 +58075,7 @@ var ts; else { if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56728,7 +58101,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56742,7 +58115,7 @@ var ts; token = nextToken(); if (token === 70 || ts.isKeyword(token)) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56768,7 +58141,7 @@ var ts; } if (token === 17) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56778,7 +58151,7 @@ var ts; } else if (token === 38) { token = nextToken(); - if (token === 137) { + if (token === 138) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -56802,7 +58175,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 130) { + if (token === 131) { token = nextToken(); if (token === 18) { token = nextToken(); @@ -57021,14 +58394,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175) { + if (argumentInfo.invocation.kind !== 178) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; var name = expression.kind === 70 ? expression - : expression.kind === 173 + : expression.kind === 176 ? expression.name : undefined; if (!name || !name.text) { @@ -57057,7 +58430,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 || node.parent.kind === 176) { + if (node.parent.kind === 178 || node.parent.kind === 179) { var callExpression = node.parent; if (node.kind === 26 || node.kind === 18) { @@ -57089,23 +58462,23 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 177) { + else if (node.kind === 12 && node.parent.kind === 180) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 177) { + else if (node.kind === 13 && node.parent.parent.kind === 180) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 193); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 198 && node.parent.parent.parent.kind === 177) { + else if (node.parent.kind === 201 && node.parent.parent.parent.kind === 180) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190); + ts.Debug.assert(templateExpression.kind === 193); if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -57169,7 +58542,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 190) { + if (template.kind === 193) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -57178,7 +58551,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 256; n = n.parent) { + for (var n = node; n.kind !== 260; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -57228,7 +58601,9 @@ var ts; if (callTargetDisplayParts) { ts.addRange(prefixDisplayParts, callTargetDisplayParts); } + var isVariadic; if (isTypeParameterList) { + isVariadic = false; prefixDisplayParts.push(ts.punctuationPart(26)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; @@ -57239,6 +58614,7 @@ var ts; ts.addRange(suffixDisplayParts, parameterParts); } else { + isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); @@ -57253,7 +58629,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], @@ -57307,7 +58683,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ts.getDeclarationOfKind(symbol, 193) ? + return ts.getDeclarationOfKind(symbol, 196) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -57407,14 +58783,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 173) { + if (location.parent && location.parent.kind === 176) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression = void 0; - if (location.kind === 175 || location.kind === 176) { + if (location.kind === 178 || location.kind === 179) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -57426,7 +58802,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 || callExpression.expression.kind === 96; + var useConstructSignatures = callExpression.kind === 179 || callExpression.expression.kind === 96; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -57474,21 +58850,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 149)) { + (location.kind === 122 && location.parent.kind === 150)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 149 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 150 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 149) { + if (functionDeclaration.kind === 150) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -57497,7 +58873,7 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193)) { + if (ts.getDeclarationOfKind(symbol, 196)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { @@ -57516,7 +58892,7 @@ var ts; } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -57537,9 +58913,9 @@ var ts; } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226); + var declaration = ts.getDeclarationOfKind(symbol, 229); var isNamespace = declaration && declaration.name && declaration.name.kind === 70; - displayParts.push(ts.keywordPart(isNamespace ? 127 : 126)); + displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -57558,23 +58934,23 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 142); + var declaration = ts.getDeclarationOfKind(symbol, 143); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 153) { + if (declaration.kind === 154) { displayParts.push(ts.keywordPart(93)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 152 && declaration.name) { + else if (declaration.kind !== 153 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } else { - displayParts.push(ts.keywordPart(135)); + displayParts.push(ts.keywordPart(136)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -57585,7 +58961,7 @@ var ts; if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255) { + if (declaration.kind === 259) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -57597,10 +58973,10 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229) { + if (symbol.declarations[0].kind === 232) { displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127)); + displayParts.push(ts.keywordPart(128)); } else { displayParts.push(ts.keywordPart(90)); @@ -57608,13 +58984,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230) { + if (declaration.kind === 233) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(57)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130)); + displayParts.push(ts.keywordPart(131)); displayParts.push(ts.punctuationPart(18)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(19)); @@ -57676,10 +59052,10 @@ var ts; if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 256; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 260; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 188) { + if (!declaration.parent || declaration.parent.kind !== 191) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -57754,14 +59130,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 180) { + if (declaration.kind === 183) { return true; } - if (declaration.kind !== 219 && declaration.kind !== 221) { + if (declaration.kind !== 222 && declaration.kind !== 224) { return false; } - for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { - if (parent_23.kind === 256 || parent_23.kind === 227) { + for (var parent_22 = declaration.parent; !ts.isFunctionBlock(parent_22); parent_22 = parent_22.parent) { + if (parent_22.kind === 260 || parent_22.kind === 230) { return false; } } @@ -57845,7 +59221,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -57861,7 +59237,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_4(opt); } return options; } @@ -57870,8 +59246,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(4, false, 0); - var jsxScanner = ts.createScanner(4, false, 1); + var standardScanner = ts.createScanner(5, false, 0); + var jsxScanner = ts.createScanner(5, false, 1); var scanner; function getFormattingScanner(sourceFile, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); @@ -57952,10 +59328,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 249: + case 247: + case 248: case 246: - case 244: - case 245: - case 243: return node.kind === 70; } } @@ -58330,13 +59706,13 @@ var ts; this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 132]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 133]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126, 130]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 126, 127, 111, 113, 112, 132, 114, 135, 137]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 137])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 133, 114, 136, 138]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84, 107, 138])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); @@ -58350,7 +59726,7 @@ var ts; this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 132, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 133, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); @@ -58455,43 +59831,43 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_51 in o) { - if (o[name_51] === rule) { - return name_51; + for (var name_47 in o) { + if (o[name_47] === rule) { + return name_47; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 207; + return context.contextNode.kind === 210; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188: - case 189: - case 196: - case 239: - case 235: - case 155: - case 163: + case 191: + case 192: + case 199: + case 242: + case 238: + case 156: case 164: + case 165: return true; - case 170: - case 224: - case 230: - case 219: - case 143: - case 255: + case 173: + case 227: + case 233: + case 222: + case 144: + case 259: + case 147: case 146: - case 145: return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 208: + case 211: return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; - case 209: - return context.currentTokenSpan.kind === 139 || context.nextTokenSpan.kind === 139; + case 212: + return context.currentTokenSpan.kind === 140 || context.nextTokenSpan.kind === 140; } return false; }; @@ -58499,7 +59875,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 192; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); @@ -58524,90 +59900,90 @@ var ts; return true; } switch (node.kind) { - case 200: - case 228: - case 172: - case 227: + case 203: + case 231: + case 175: + case 230: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221: + case 224: + case 149: case 148: - case 147: - case 150: case 151: case 152: - case 180: - case 149: - case 181: - case 223: + case 153: + case 183: + case 150: + case 184: + case 226: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 || context.contextNode.kind === 180; + return context.contextNode.kind === 224 || context.contextNode.kind === 183; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 222: - case 193: - case 223: case 225: - case 160: + case 196: case 226: - case 237: - case 238: - case 231: + case 228: + case 161: + case 229: + case 240: + case 241: case 234: + case 237: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 222: - case 226: case 225: - case 200: - case 252: - case 227: - case 214: + case 229: + case 228: + case 203: + case 255: + case 230: + case 217: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 204: - case 214: case 207: - case 208: - case 209: - case 206: case 217: - case 205: - case 213: - case 252: + case 210: + case 211: + case 212: + case 209: + case 220: + case 208: + case 216: + case 255: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172; - }; - Rules.IsFunctionCallContext = function (context) { return context.contextNode.kind === 175; }; + Rules.IsFunctionCallContext = function (context) { + return context.contextNode.kind === 178; + }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176; + return context.contextNode.kind === 179; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -58619,25 +59995,25 @@ var ts; return context.nextTokenSpan.kind !== 21; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 184; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242; + return context.contextNode.kind !== 245; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248; + return context.contextNode.kind === 251; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246; + return context.nextTokenParent.kind === 249; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246; + return context.contextNode.kind === 249; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243; + return context.contextNode.kind === 246; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -58652,41 +60028,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 144; + return node.kind === 145; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 220 && + return context.currentTokenParent.kind === 223 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 226; + return context.contextNode.kind === 229; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 160; + return context.contextNode.kind === 161; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 && token.kind !== 28) { return false; } switch (parent.kind) { - case 156: - case 178: - case 222: - case 193: - case 223: - case 221: - case 180: + case 157: case 181: + case 225: + case 196: + case 226: + case 224: + case 183: + case 184: + case 149: case 148: - case 147: - case 152: case 153: - case 175: - case 176: - case 195: + case 154: + case 178: + case 179: + case 198: return true; default: return false; @@ -58697,13 +60073,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178; + return context.contextNode.kind === 181; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 184; + return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 187; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 194 && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -58725,7 +60101,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 139 + 1; + this.mapRowLength = 140 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -58738,7 +60114,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 139 && column <= 139, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 140 && column <= 140, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -58775,6 +60151,7 @@ var ts; formatting.RulesMap = RulesMap; var MaskBitSize = 5; var Mask = 0x1f; + var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; @@ -58782,8 +60159,7 @@ var ts; RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; + })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); var RulesBucketConstructionState = (function () { function RulesBucketConstructionState() { this.rulesInsertionIndexBitmap = 0; @@ -58902,7 +60278,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 139; token++) { + for (var token = 0; token <= 140; token++) { result.push(token); } return result; @@ -58946,9 +60322,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 139); + TokenRange.Keywords = TokenRange.FromRange(71, 140); TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 139, 117, 125]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 140, 117, 125]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); @@ -58956,7 +60332,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 131, 133, 121, 134, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 134, 121, 135, 104, 118]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -59164,17 +60540,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 222: - case 223: - return ts.rangeContainsRange(parent.members, node); + case 225: case 226: + return ts.rangeContainsRange(parent.members, node); + case 229: var body = parent.body; - return body && body.kind === 227 && ts.rangeContainsRange(body.statements, node); - case 256: - case 200: - case 227: + return body && body.kind === 230 && ts.rangeContainsRange(body.statements, node); + case 260: + case 203: + case 230: return ts.rangeContainsRange(parent.statements, node); - case 252: + case 255: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -59330,18 +60706,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 222: return 74; - case 223: return 108; - case 221: return 88; - case 225: return 225; - case 150: return 124; - case 151: return 132; - case 148: + case 225: return 74; + case 226: return 108; + case 224: return 88; + case 228: return 228; + case 151: return 124; + case 152: return 133; + case 149: if (node.asteriskToken) { return 38; } - case 146: - case 143: + case 147: + case 144: return node.name.kind; } } @@ -59457,11 +60833,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 144 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 145 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 171 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 174 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -59765,12 +61141,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { + case 150: + case 224: + case 183: case 149: - case 221: - case 180: case 148: - case 147: - case 181: + case 184: if (node.typeParameters === list) { return 26; } @@ -59778,8 +61154,8 @@ var ts; return 18; } break; - case 175: - case 176: + case 178: + case 179: if (node.typeArguments === list) { return 26; } @@ -59787,7 +61163,7 @@ var ts; return 18; } break; - case 156: + case 157: if (node.typeArguments === list) { return 26; } @@ -59888,7 +61264,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 188) { + if (precedingToken.kind === 25 && precedingToken.parent.kind !== 191) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -59990,7 +61366,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 256 || !parentAndChildShareLine); + (parent.kind === 260 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -60014,7 +61390,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 204 && parent.elseStatement === child) { + if (parent.kind === 207 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -60026,23 +61402,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 156: + case 157: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 172: + case 175: return node.parent.properties; - case 171: + case 174: return node.parent.elements; - case 221: - case 180: - case 181: + case 224: + case 183: + case 184: + case 149: case 148: - case 147: - case 152: - case 153: { + case 153: + case 154: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -60053,8 +61429,8 @@ var ts; } break; } - case 176: - case 175: { + case 179: + case 178: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -60082,8 +61458,8 @@ var ts; if (node.kind === 19) { return -1; } - if (node.parent && (node.parent.kind === 175 || - node.parent.kind === 176) && + if (node.parent && (node.parent.kind === 178 || + node.parent.kind === 179) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -60101,10 +61477,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175: + case 178: + case 179: case 176: - case 173: - case 174: + case 177: node = node.expression; break; default: @@ -60158,48 +61534,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203: - case 222: - case 193: - case 223: + case 206: case 225: - case 224: - case 171: - case 200: - case 227: - case 172: - case 160: - case 162: + case 196: + case 226: case 228: - case 250: - case 249: - case 179: - case 173: + case 227: + case 174: + case 203: + case 230: case 175: + case 161: + case 163: + case 231: + case 253: + case 252: + case 182: case 176: - case 201: - case 219: - case 236: - case 212: - case 189: - case 169: - case 168: - case 244: - case 243: - case 248: - case 147: - case 152: - case 153: - case 143: - case 157: - case 158: - case 165: - case 177: - case 185: - case 238: - case 234: + case 178: + case 179: + case 204: + case 222: case 239: - case 235: + case 215: + case 192: + case 172: + case 171: + case 247: + case 246: + case 251: + case 148: + case 153: + case 154: + case 144: + case 158: + case 159: + case 166: + case 180: + case 188: + case 241: + case 237: + case 242: + case 238: return true; } return false; @@ -60207,27 +61583,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 205: - case 206: case 208: case 209: + case 211: + case 212: + case 210: case 207: - case 204: - case 221: - case 180: - case 148: - case 181: + case 224: + case 183: case 149: + case 184: case 150: case 151: - return childKind !== 200; - case 237: - return childKind !== 238; - case 231: - return childKind !== 232 || - (child.namedBindings && child.namedBindings.kind !== 234); - case 242: - return childKind !== 245; + case 152: + return childKind !== 203; + case 240: + return childKind !== 241; + case 234: + return childKind !== 235 || + (child.namedBindings && child.namedBindings.kind !== 237); + case 245: + return childKind !== 248; } return indentByDefault; } @@ -60308,7 +61684,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 175) { + if (superCall.expression && superCall.expression.kind == 178) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -60332,7 +61708,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 && ts.isSuperCall(n.expression)) { + if (n.kind === 206 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -60348,7 +61724,7 @@ var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 140 ? new NodeObject(kind, pos, end) : + var node = kind >= 141 ? new NodeObject(kind, pos, end) : kind === 70 ? new IdentifierObject(70, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -60406,11 +61782,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286, nodes.pos, nodes.end, this); + var list = createNode(290, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -60425,11 +61801,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 140) { + if (this.kind >= 141) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285; + var useJSDocScanner_1 = this.kind >= 277 && this.kind <= 289; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -60483,7 +61859,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 140 ? child : child.getFirstToken(sourceFile); + return child.kind < 141 ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -60491,7 +61867,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 140 ? child : child.getLastToken(sourceFile); + return child.kind < 141 ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -60693,9 +62069,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 141) { + if (declaration.name.kind === 142) { var expr = declaration.name.expression; - if (expr.kind === 173) { + if (expr.kind === 176) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -60715,10 +62091,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221: - case 180: + case 224: + case 183: + case 149: case 148: - case 147: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -60735,30 +62111,30 @@ var ts; ts.forEachChild(node, visit); } break; - case 222: - case 193: - case 223: - case 224: case 225: + case 196: case 226: - case 230: - case 239: - case 235: - case 230: - case 232: + case 227: + case 228: + case 229: case 233: - case 150: + case 242: + case 238: + case 233: + case 235: + case 236: case 151: - case 160: + case 152: + case 161: addDeclaration(node); ts.forEachChild(node, visit); break; - case 143: + case 144: if (!ts.hasModifier(node, 92)) { break; } - case 219: - case 170: { + case 222: + case 173: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -60767,24 +62143,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255: + case 259: + case 147: case 146: - case 145: addDeclaration(node); break; - case 237: + case 240: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231: + case 234: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233) { + if (importClause.namedBindings.kind === 236) { addDeclaration(importClause.namedBindings); } else { @@ -60930,7 +62306,7 @@ var ts; var version = this.host.getScriptVersion(fileName); var sourceFile; if (this.currentFileName !== fileName) { - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4, version, true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 5, version, true, scriptKind); } else if (this.currentFileVersion !== version) { var editRange = scriptSnapshot.getChangeRange(this.currentFileScriptSnapshot); @@ -61226,10 +62602,10 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 70: - case 173: - case 140: + case 176: + case 141: case 98: - case 166: + case 167: case 96: var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -61358,15 +62734,15 @@ var ts; return; } switch (node.kind) { - case 173: - case 140: + case 176: + case 141: case 9: case 85: case 100: case 94: case 96: case 98: - case 166: + case 167: case 70: break; default: @@ -61378,7 +62754,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 226 && + if (nodeForStartPos.parent.parent.kind === 229 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -61674,7 +63050,7 @@ var ts; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 241 || + node.parent.kind === 244 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -61694,7 +63070,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 && + node.parent.kind === 177 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -61875,37 +63251,28 @@ var ts; this.host = host; this.project = project; this.cancellationToken = cancellationToken; - this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.resolvedModuleNames = ts.createFileMap(); this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { this.trace = function (s) { return host.trace(s); }; } this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { + var globalCache = _this.project.getTypingOptions().enableAutoDiscovery + ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation + : undefined; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); - if (primaryResult.resolvedModule) { - if (ts.fileExtensionIsAny(primaryResult.resolvedModule.resolvedFileName, ts.supportedTypeScriptExtensions)) { - return primaryResult; + if (!(primaryResult.resolvedModule && ts.extensionIsTypeScript(primaryResult.resolvedModule.extension)) && globalCache !== undefined) { + var _a = ts.loadModuleFromGlobalCache(moduleName, _this.project.getProjectName(), compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; + if (resolvedModule) { + return { resolvedModule: resolvedModule, failedLookupLocations: primaryResult.failedLookupLocations.concat(failedLookupLocations) }; } } - var secondaryLookupFailedLookupLocations = []; - var globalCache = _this.project.projectService.typingsInstaller.globalTypingsCacheLocation; - if (_this.project.getTypingOptions().enableAutoDiscovery && globalCache) { - var traceEnabled = ts.isTraceEnabled(compilerOptions, host); - if (traceEnabled) { - ts.trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, _this.project.getProjectName(), moduleName, globalCache); - } - var state = { compilerOptions: compilerOptions, host: host, skipTsx: false, traceEnabled: traceEnabled }; - var resolvedName = ts.loadModuleFromNodeModules(moduleName, globalCache, secondaryLookupFailedLookupLocations, state, true); - if (resolvedName) { - return ts.createResolvedModule(resolvedName, true, primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations)); - } - } - if (!primaryResult.resolvedModule && secondaryLookupFailedLookupLocations.length) { - primaryResult.failedLookupLocations = primaryResult.failedLookupLocations.concat(secondaryLookupFailedLookupLocations); - } return primaryResult; }; + if (this.host.realpath) { + this.realpath = function (path) { return _this.host.realpath(path); }; + } } LSHost.prototype.startRecordingFilesWithChangedResolutions = function () { this.filesWithChangedSetOfUnresolvedImports = []; @@ -61915,23 +63282,23 @@ var ts; this.filesWithChangedSetOfUnresolvedImports = undefined; return collected; }; - LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, logChanges) { + LSHost.prototype.resolveNamesWithLocalCache = function (names, containingFile, cache, loader, getResult, getResultFileName, logChanges) { var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); var currentResolutionsInFile = cache.get(path); var newResolutions = ts.createMap(); var resolvedModules = []; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name_52 = names_3[_i]; - var resolution = newResolutions[name_52]; + for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { + var name_48 = names_2[_i]; + var resolution = newResolutions[name_48]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_52]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_48]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_52] = resolution = loader(name_52, containingFile, compilerOptions, this); + newResolutions[name_48] = resolution = loader(name_48, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -61958,7 +63325,7 @@ var ts; if (!oldResult || !newResult) { return false; } - return oldResult.resolvedFileName === newResult.resolvedFileName; + return getResultFileName(oldResult) === getResultFileName(newResult); } function moduleResolutionIsValid(resolution) { if (!resolution) { @@ -61966,10 +63333,7 @@ var ts; } var result = getResult(resolution); if (result) { - if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) { - return false; - } - return true; + return getResultFileName(result) !== lastDeletedFileName; } return resolution.failedLookupLocations.length === 0; } @@ -61987,10 +63351,10 @@ var ts; return this.cancellationToken; }; LSHost.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, false); + return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, function (m) { return m.resolvedTypeReferenceDirective; }, function (r) { return r.resolvedFileName; }, false); }; LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, true); + return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, this.resolveModuleName, function (m) { return m.resolvedModule; }, function (r) { return r.resolvedFileName; }, true); }; LSHost.prototype.getDefaultLibFileName = function () { var nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath())); @@ -62163,7 +63527,6 @@ var ts; (function (ts) { var server; (function (server) { - var crypto = require("crypto"); function shouldEmitFile(scriptInfo) { return !scriptInfo.hasMixedContent; } @@ -62180,16 +63543,14 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 226 || statement.name.kind !== 9) { + if (statement.kind !== 229 || statement.name.kind !== 9) { return false; } } return true; }; BuilderFileInfo.prototype.computeHash = function (text) { - return crypto.createHash("md5") - .update(text) - .digest("base64"); + return this.project.projectService.host.createHash(text); }; BuilderFileInfo.prototype.getSourceFile = function () { return this.project.getSourceFile(this.scriptInfo.path); @@ -62465,12 +63826,12 @@ var ts; (function (ts) { var server; (function (server) { + var ProjectKind; (function (ProjectKind) { ProjectKind[ProjectKind["Inferred"] = 0] = "Inferred"; ProjectKind[ProjectKind["Configured"] = 1] = "Configured"; ProjectKind[ProjectKind["External"] = 2] = "External"; - })(server.ProjectKind || (server.ProjectKind = {})); - var ProjectKind = server.ProjectKind; + })(ProjectKind = server.ProjectKind || (server.ProjectKind = {})); function remove(items, item) { var index = items.indexOf(item); if (index >= 0) { @@ -62563,8 +63924,8 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } - if (this.projectKind === ProjectKind.Inferred) { - this.compilerOptions.noEmitOverwritenFiles = true; + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; } if (languageServiceEnabled) { this.enableLanguageService(); @@ -62692,7 +64053,7 @@ var ts; } return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles); }; - Project.prototype.getFileNames = function () { + Project.prototype.getFileNames = function (excludeFilesFromExternalLibraries) { if (!this.program) { return []; } @@ -62706,8 +64067,15 @@ var ts; } return rootFiles; } - var sourceFiles = this.program.getSourceFiles(); - return sourceFiles.map(function (sourceFile) { return server.asNormalizedPath(sourceFile.fileName); }); + var result = []; + for (var _i = 0, _a = this.program.getSourceFiles(); _i < _a.length; _i++) { + var f = _a[_i]; + if (excludeFilesFromExternalLibraries && this.program.isSourceFileFromExternalLibrary(f)) { + continue; + } + result.push(server.asNormalizedPath(f.fileName)); + } + return result; }; Project.prototype.getAllEmittableFiles = function () { if (!this.languageServiceEnabled) { @@ -62768,9 +64136,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_53 in file.resolvedModules) { - if (!file.resolvedModules[name_53] && !ts.isExternalModuleNameRelative(name_53)) { - var trimmed = name_53.trim(); + for (var name_49 in file.resolvedModules) { + if (!file.resolvedModules[name_49] && !ts.isExternalModuleNameRelative(name_49)) { + var trimmed = name_49.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -62991,9 +64359,8 @@ var ts; server.Project = Project; var InferredProject = (function (_super) { __extends(InferredProject, _super); - function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.compileOnSaveEnabled = compileOnSaveEnabled; + function InferredProject(projectService, documentRegistry, languageServiceEnabled, compilerOptions) { + var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, languageServiceEnabled, compilerOptions, false) || this; _this.directoriesWatchedForTsconfig = []; _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); InferredProject.NextId++; @@ -63323,6 +64690,7 @@ var ts; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; + ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); this.throttledOperations = new server.ThrottledOperations(host); @@ -63360,6 +64728,7 @@ var ts; }; ProjectService.prototype.setCompilerOptionsForInferredProjects = function (projectCompilerOptions) { this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions); + this.compilerOptionsForInferredProjects.allowNonTsExtensions = true; this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave; for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var proj = _a[_i]; @@ -63910,7 +65279,7 @@ var ts; var useExistingProject = this.useSingleInferredProject && this.inferredProjects.length; var project = useExistingProject ? this.inferredProjects[0] - : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects, this.compileOnSaveForInferredProjects); + : new server.InferredProject(this, this.documentRegistry, true, this.compilerOptionsForInferredProjects); project.addRoot(root); this.directoryWatchers.startWatchingContainingDirectoriesForFile(root.fileName, project, function (fileName) { return _this.onConfigFileAddedForInferredProject(fileName); }); project.updateGraph(); @@ -64043,13 +65412,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -64139,7 +65508,9 @@ var ts; var file = _a[_i]; var normalized = server.toNormalizedPath(file.fileName); if (ts.getBaseFileName(normalized) === "tsconfig.json") { - (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + if (this.host.fileExists(normalized)) { + (tsConfigFiles || (tsConfigFiles = [])).push(normalized); + } } else { rootFiles.push(file); @@ -65272,9 +66643,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_54 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_50 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_54, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_50, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -65677,6 +67048,7 @@ var ts; var server; (function (server) { var lineCollectionCapacity = 4; + var CharRangeSection; (function (CharRangeSection) { CharRangeSection[CharRangeSection["PreStart"] = 0] = "PreStart"; CharRangeSection[CharRangeSection["Start"] = 1] = "Start"; @@ -65684,8 +67056,7 @@ var ts; CharRangeSection[CharRangeSection["Mid"] = 3] = "Mid"; CharRangeSection[CharRangeSection["End"] = 4] = "End"; CharRangeSection[CharRangeSection["PostEnd"] = 5] = "PostEnd"; - })(server.CharRangeSection || (server.CharRangeSection = {})); - var CharRangeSection = server.CharRangeSection; + })(CharRangeSection = server.CharRangeSection || (server.CharRangeSection = {})); var BaseLineIndexWalker = (function () { function BaseLineIndexWalker() { this.goSubtree = true; @@ -66563,7 +67934,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 0cd76cfaf68..de919cd9f31 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -163,170 +163,176 @@ declare namespace ts { DeclareKeyword = 123, GetKeyword = 124, IsKeyword = 125, - ModuleKeyword = 126, - NamespaceKeyword = 127, - NeverKeyword = 128, - ReadonlyKeyword = 129, - RequireKeyword = 130, - NumberKeyword = 131, - SetKeyword = 132, - StringKeyword = 133, - SymbolKeyword = 134, - TypeKeyword = 135, - UndefinedKeyword = 136, - FromKeyword = 137, - GlobalKeyword = 138, - OfKeyword = 139, - QualifiedName = 140, - ComputedPropertyName = 141, - TypeParameter = 142, - Parameter = 143, - Decorator = 144, - PropertySignature = 145, - PropertyDeclaration = 146, - MethodSignature = 147, - MethodDeclaration = 148, - Constructor = 149, - GetAccessor = 150, - SetAccessor = 151, - CallSignature = 152, - ConstructSignature = 153, - IndexSignature = 154, - TypePredicate = 155, - TypeReference = 156, - FunctionType = 157, - ConstructorType = 158, - TypeQuery = 159, - TypeLiteral = 160, - ArrayType = 161, - TupleType = 162, - UnionType = 163, - IntersectionType = 164, - ParenthesizedType = 165, - ThisType = 166, - LiteralType = 167, - ObjectBindingPattern = 168, - ArrayBindingPattern = 169, - BindingElement = 170, - ArrayLiteralExpression = 171, - ObjectLiteralExpression = 172, - PropertyAccessExpression = 173, - ElementAccessExpression = 174, - CallExpression = 175, - NewExpression = 176, - TaggedTemplateExpression = 177, - TypeAssertionExpression = 178, - ParenthesizedExpression = 179, - FunctionExpression = 180, - ArrowFunction = 181, - DeleteExpression = 182, - TypeOfExpression = 183, - VoidExpression = 184, - AwaitExpression = 185, - PrefixUnaryExpression = 186, - PostfixUnaryExpression = 187, - BinaryExpression = 188, - ConditionalExpression = 189, - TemplateExpression = 190, - YieldExpression = 191, - SpreadElementExpression = 192, - ClassExpression = 193, - OmittedExpression = 194, - ExpressionWithTypeArguments = 195, - AsExpression = 196, - NonNullExpression = 197, - TemplateSpan = 198, - SemicolonClassElement = 199, - Block = 200, - VariableStatement = 201, - EmptyStatement = 202, - ExpressionStatement = 203, - IfStatement = 204, - DoStatement = 205, - WhileStatement = 206, - ForStatement = 207, - ForInStatement = 208, - ForOfStatement = 209, - ContinueStatement = 210, - BreakStatement = 211, - ReturnStatement = 212, - WithStatement = 213, - SwitchStatement = 214, - LabeledStatement = 215, - ThrowStatement = 216, - TryStatement = 217, - DebuggerStatement = 218, - VariableDeclaration = 219, - VariableDeclarationList = 220, - FunctionDeclaration = 221, - ClassDeclaration = 222, - InterfaceDeclaration = 223, - TypeAliasDeclaration = 224, - EnumDeclaration = 225, - ModuleDeclaration = 226, - ModuleBlock = 227, - CaseBlock = 228, - NamespaceExportDeclaration = 229, - ImportEqualsDeclaration = 230, - ImportDeclaration = 231, - ImportClause = 232, - NamespaceImport = 233, - NamedImports = 234, - ImportSpecifier = 235, - ExportAssignment = 236, - ExportDeclaration = 237, - NamedExports = 238, - ExportSpecifier = 239, - MissingDeclaration = 240, - ExternalModuleReference = 241, - JsxElement = 242, - JsxSelfClosingElement = 243, - JsxOpeningElement = 244, - JsxClosingElement = 245, - JsxAttribute = 246, - JsxSpreadAttribute = 247, - JsxExpression = 248, - CaseClause = 249, - DefaultClause = 250, - HeritageClause = 251, - CatchClause = 252, - PropertyAssignment = 253, - ShorthandPropertyAssignment = 254, - EnumMember = 255, - SourceFile = 256, - JSDocTypeExpression = 257, - JSDocAllType = 258, - JSDocUnknownType = 259, - JSDocArrayType = 260, - JSDocUnionType = 261, - JSDocTupleType = 262, - JSDocNullableType = 263, - JSDocNonNullableType = 264, - JSDocRecordType = 265, - JSDocRecordMember = 266, - JSDocTypeReference = 267, - JSDocOptionalType = 268, - JSDocFunctionType = 269, - JSDocVariadicType = 270, - JSDocConstructorType = 271, - JSDocThisType = 272, - JSDocComment = 273, - JSDocTag = 274, - JSDocParameterTag = 275, - JSDocReturnTag = 276, - JSDocTypeTag = 277, - JSDocTemplateTag = 278, - JSDocTypedefTag = 279, - JSDocPropertyTag = 280, - JSDocTypeLiteral = 281, - JSDocLiteralType = 282, - JSDocNullKeyword = 283, - JSDocUndefinedKeyword = 284, - JSDocNeverKeyword = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - Count = 289, + KeyOfKeyword = 126, + ModuleKeyword = 127, + NamespaceKeyword = 128, + NeverKeyword = 129, + ReadonlyKeyword = 130, + RequireKeyword = 131, + NumberKeyword = 132, + SetKeyword = 133, + StringKeyword = 134, + SymbolKeyword = 135, + TypeKeyword = 136, + UndefinedKeyword = 137, + FromKeyword = 138, + GlobalKeyword = 139, + OfKeyword = 140, + QualifiedName = 141, + ComputedPropertyName = 142, + TypeParameter = 143, + Parameter = 144, + Decorator = 145, + PropertySignature = 146, + PropertyDeclaration = 147, + MethodSignature = 148, + MethodDeclaration = 149, + Constructor = 150, + GetAccessor = 151, + SetAccessor = 152, + CallSignature = 153, + ConstructSignature = 154, + IndexSignature = 155, + TypePredicate = 156, + TypeReference = 157, + FunctionType = 158, + ConstructorType = 159, + TypeQuery = 160, + TypeLiteral = 161, + ArrayType = 162, + TupleType = 163, + UnionType = 164, + IntersectionType = 165, + ParenthesizedType = 166, + ThisType = 167, + TypeOperator = 168, + IndexedAccessType = 169, + LiteralType = 170, + ObjectBindingPattern = 171, + ArrayBindingPattern = 172, + BindingElement = 173, + ArrayLiteralExpression = 174, + ObjectLiteralExpression = 175, + PropertyAccessExpression = 176, + ElementAccessExpression = 177, + CallExpression = 178, + NewExpression = 179, + TaggedTemplateExpression = 180, + TypeAssertionExpression = 181, + ParenthesizedExpression = 182, + FunctionExpression = 183, + ArrowFunction = 184, + DeleteExpression = 185, + TypeOfExpression = 186, + VoidExpression = 187, + AwaitExpression = 188, + PrefixUnaryExpression = 189, + PostfixUnaryExpression = 190, + BinaryExpression = 191, + ConditionalExpression = 192, + TemplateExpression = 193, + YieldExpression = 194, + SpreadElement = 195, + ClassExpression = 196, + OmittedExpression = 197, + ExpressionWithTypeArguments = 198, + AsExpression = 199, + NonNullExpression = 200, + TemplateSpan = 201, + SemicolonClassElement = 202, + Block = 203, + VariableStatement = 204, + EmptyStatement = 205, + ExpressionStatement = 206, + IfStatement = 207, + DoStatement = 208, + WhileStatement = 209, + ForStatement = 210, + ForInStatement = 211, + ForOfStatement = 212, + ContinueStatement = 213, + BreakStatement = 214, + ReturnStatement = 215, + WithStatement = 216, + SwitchStatement = 217, + LabeledStatement = 218, + ThrowStatement = 219, + TryStatement = 220, + DebuggerStatement = 221, + VariableDeclaration = 222, + VariableDeclarationList = 223, + FunctionDeclaration = 224, + ClassDeclaration = 225, + InterfaceDeclaration = 226, + TypeAliasDeclaration = 227, + EnumDeclaration = 228, + ModuleDeclaration = 229, + ModuleBlock = 230, + CaseBlock = 231, + NamespaceExportDeclaration = 232, + ImportEqualsDeclaration = 233, + ImportDeclaration = 234, + ImportClause = 235, + NamespaceImport = 236, + NamedImports = 237, + ImportSpecifier = 238, + ExportAssignment = 239, + ExportDeclaration = 240, + NamedExports = 241, + ExportSpecifier = 242, + MissingDeclaration = 243, + ExternalModuleReference = 244, + JsxElement = 245, + JsxSelfClosingElement = 246, + JsxOpeningElement = 247, + JsxClosingElement = 248, + JsxAttribute = 249, + JsxSpreadAttribute = 250, + JsxExpression = 251, + CaseClause = 252, + DefaultClause = 253, + HeritageClause = 254, + CatchClause = 255, + PropertyAssignment = 256, + ShorthandPropertyAssignment = 257, + SpreadAssignment = 258, + EnumMember = 259, + SourceFile = 260, + JSDocTypeExpression = 261, + JSDocAllType = 262, + JSDocUnknownType = 263, + JSDocArrayType = 264, + JSDocUnionType = 265, + JSDocTupleType = 266, + JSDocNullableType = 267, + JSDocNonNullableType = 268, + JSDocRecordType = 269, + JSDocRecordMember = 270, + JSDocTypeReference = 271, + JSDocOptionalType = 272, + JSDocFunctionType = 273, + JSDocVariadicType = 274, + JSDocConstructorType = 275, + JSDocThisType = 276, + JSDocComment = 277, + JSDocTag = 278, + JSDocParameterTag = 279, + JSDocReturnTag = 280, + JSDocTypeTag = 281, + JSDocTemplateTag = 282, + JSDocTypedefTag = 283, + JSDocPropertyTag = 284, + JSDocTypeLiteral = 285, + JSDocLiteralType = 286, + JSDocNullKeyword = 287, + JSDocUndefinedKeyword = 288, + JSDocNeverKeyword = 289, + SyntaxList = 290, + NotEmittedStatement = 291, + PartiallyEmittedExpression = 292, + MergeDeclarationMarker = 293, + EndOfDeclarationMarker = 294, + Count = 295, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -334,15 +340,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 139, + LastKeyword = 140, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 155, - LastTypeNode = 167, + FirstTypeNode = 156, + LastTypeNode = 170, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -351,11 +357,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 261, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 289, } enum NodeFlags { None = 0, @@ -373,21 +379,22 @@ declare namespace ts { HasDecorators = 2048, HasParamDecorators = 4096, HasAsyncFunctions = 8192, - HasJsxSpreadAttributes = 16384, - DisallowInContext = 32768, - YieldContext = 65536, - DecoratorContext = 131072, - AwaitContext = 262144, - ThisNodeHasError = 524288, - JavaScriptFile = 1048576, - ThisNodeOrAnySubNodesHasError = 2097152, - HasAggregatedChildData = 4194304, + HasSpreadAttribute = 16384, + HasRestAttribute = 32768, + DisallowInContext = 65536, + YieldContext = 131072, + DecoratorContext = 262144, + AwaitContext = 524288, + ThisNodeHasError = 1048576, + JavaScriptFile = 2097152, + ThisNodeOrAnySubNodesHasError = 4194304, + HasAggregatedChildData = 8388608, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 31744, - ReachabilityAndEmitFlags = 32128, - ContextFlags = 1540096, - TypeExcludesFlags = 327680, + EmitHelperFlags = 64512, + ReachabilityAndEmitFlags = 64896, + ContextFlags = 3080192, + TypeExcludesFlags = 655360, } enum ModifierFlags { None = 0, @@ -407,6 +414,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } enum JsxFlags { None = 0, @@ -534,7 +542,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -548,6 +556,10 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } + interface SpreadAssignment extends ObjectLiteralElement { + kind: SyntaxKind.SpreadAssignment; + expression: Expression; + } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; @@ -678,6 +690,16 @@ declare namespace ts { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } + interface TypeOperatorNode extends TypeNode { + kind: SyntaxKind.TypeOperator; + operator: SyntaxKind.KeyOfKeyword; + type: TypeNode; + } + interface IndexedAccessTypeNode extends TypeNode { + kind: SyntaxKind.IndexedAccessType; + objectType: TypeNode; + indexType: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; @@ -710,9 +732,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -781,6 +800,17 @@ declare namespace ts { operatorToken: BinaryOperatorToken; right: Expression; } + interface AssignmentExpression extends BinaryExpression { + left: LeftHandSideExpression; + operatorToken: Token; + } + interface ObjectDestructuringAssignment extends AssignmentExpression { + left: ObjectLiteralExpression; + } + interface ArrayDestructuringAssignment extends AssignmentExpression { + left: ArrayLiteralExpression; + } + type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; @@ -847,8 +877,8 @@ declare namespace ts { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElementExpression extends Expression { - kind: SyntaxKind.SpreadElementExpression; + interface SpreadElement extends Expression { + kind: SyntaxKind.SpreadElement; expression: Expression; } /** @@ -1717,6 +1747,8 @@ declare namespace ts { Object = 32768, Union = 65536, Intersection = 131072, + Index = 262144, + IndexedAccess = 524288, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1726,8 +1758,8 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 245760, - Narrowable = 246783, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, NotUnionOrUnit = 33281, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -1798,6 +1830,13 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } + interface IndexType extends Type { + type: TypeParameter; + } + interface IndexedAccessType extends Type { + objectType: Type; + indexType: TypeParameter; + } enum SignatureKind { Call = 0, Construct = 1, @@ -1899,6 +1938,7 @@ declare namespace ts { preserveConstEnums?: boolean; project?: string; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -1965,12 +2005,14 @@ declare namespace ts { ES2015 = 2, ES2016 = 3, ES2017 = 4, - Latest = 4, + ESNext = 5, + Latest = 5, } enum LanguageVariant { Standard = 0, JSX = 1, } + /** Either a parsed command line or a parsed tsconfig.json */ interface ParsedCommandLine { options: CompilerOptions; typingOptions?: TypingOptions; @@ -1997,12 +2039,45 @@ declare namespace ts { getCurrentDirectory?(): string; getDirectories?(path: string): string[]; } + /** + * Represents the result of module resolution. + * Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off. + * The Program will then filter results based on these flags. + * + * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. + */ interface ResolvedModule { + /** Path of the file the module was resolved to. */ resolvedFileName: string; + /** + * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module: + * - be a .d.ts file + * - use top level imports\exports + * - don't use tripleslash references + */ isExternalLibraryImport?: boolean; } + /** + * ResolvedModule with an explicitly provided `extension` property. + * Prefer this over `ResolvedModule`. + */ + interface ResolvedModuleFull extends ResolvedModule { + /** + * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. + * This is optional for backwards-compatibility, but will be added if not provided. + */ + extension: Extension; + } + enum Extension { + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, + } interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; + resolvedModule: ResolvedModuleFull | undefined; failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { @@ -2060,7 +2135,11 @@ declare namespace ts { readFile(path: string, encoding?: string): string; getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; + /** + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * use native OS file watching + */ + watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; @@ -2179,6 +2258,7 @@ declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } @@ -2192,7 +2272,7 @@ declare namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -2208,7 +2288,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.2"; + const version = "2.1.3"; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; diff --git a/lib/typescript.js b/lib/typescript.js index fd0da3fb87f..23bd3d859c1 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -22,6 +22,7 @@ var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync + var SyntaxKind; (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -160,191 +161,197 @@ var ts; SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["LiteralType"] = 170] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 171] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 172] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 173] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 174] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 175] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 176] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 177] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 178] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 179] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 180] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 181] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 182] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 183] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 184] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 185] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 186] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 187] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 188] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 189] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 190] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 191] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 192] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 193] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 194] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 195] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 196] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 197] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 198] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 199] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 200] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 201] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 202] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 203] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 204] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 205] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 206] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 207] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 208] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 209] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 210] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 211] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 212] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 213] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 214] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 215] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 216] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 217] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 218] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 219] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 220] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 221] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 222] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 223] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 224] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 225] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 226] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 227] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 228] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 229] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 230] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 231] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 232] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 233] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 234] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 235] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 236] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 237] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 238] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 239] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 240] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 241] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 242] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 243] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 244] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 245] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 246] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 247] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 248] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 249] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 250] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 251] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 252] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 253] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 254] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 255] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 256] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 257] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 258] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 259] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 260] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 261] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 262] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 263] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 264] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 265] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 266] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 267] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 268] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 269] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 270] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 271] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 272] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 273] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 274] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 275] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 276] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 277] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 278] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 279] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 280] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 281] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 282] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 283] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 284] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 285] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 286] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 287] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 288] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 289] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 290] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 291] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 292] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 293] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 294] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 295] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -353,15 +360,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 170] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -370,13 +377,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; + SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 261] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 286] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 277] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 289] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; NodeFlags[NodeFlags["Let"] = 1] = "Let"; @@ -393,25 +400,26 @@ var ts; NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; - NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["HasSpreadAttribute"] = 16384] = "HasSpreadAttribute"; + NodeFlags[NodeFlags["HasRestAttribute"] = 32768] = "HasRestAttribute"; + NodeFlags[NodeFlags["DisallowInContext"] = 65536] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 131072] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 262144] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 524288] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 1048576] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 2097152] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 4194304] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 8388608] = "HasAggregatedChildData"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 64512] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 64896] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 3080192] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 655360] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; (function (ModifierFlags) { ModifierFlags[ModifierFlags["None"] = 0] = "None"; ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; @@ -431,8 +439,9 @@ var ts; ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; (function (JsxFlags) { JsxFlags[JsxFlags["None"] = 0] = "None"; /** An element from a named property of the JSX.IntrinsicElements interface */ @@ -440,24 +449,24 @@ var ts; /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); /* @internal */ + var RelationComparisonResult; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; - })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); - var RelationComparisonResult = ts.RelationComparisonResult; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ + var GeneratedIdentifierKind; (function (GeneratedIdentifierKind) { GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; - })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); - var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; FlowFlags[FlowFlags["Start"] = 2] = "Start"; @@ -472,8 +481,7 @@ var ts; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -481,6 +489,7 @@ var ts; }()); ts.OperationCanceledException = OperationCanceledException; /** Return code used by getEmitOutput function to indicate status of the function */ + var ExitStatus; (function (ExitStatus) { // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, // when -version or -help was provided, or this was a normal compilation, no diagnostics @@ -490,8 +499,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; // Diagnostics were produced and outputs were generated in spite of them. ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; @@ -505,8 +514,8 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; (function (SymbolFormatFlags) { SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; // Write symbols's type argument if it is instantiated symbol @@ -518,23 +527,29 @@ var ts; // eg. module m { export class c { } } import x = m.c; // When this flag is specified m.c will be used to refer to the class instead of alias symbol x SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); /* @internal */ + var SymbolAccessibility; (function (SymbolAccessibility) { SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; - })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); - var SymbolAccessibility = ts.SymbolAccessibility; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + /* @internal */ + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator * metadata */ /* @internal */ + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; // should be emitted using a safe fallback. @@ -552,8 +567,8 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; // with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; (function (SymbolFlags) { SymbolFlags[SymbolFlags["None"] = 0] = "None"; SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; @@ -628,9 +643,9 @@ var ts; // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; @@ -652,8 +667,8 @@ var ts; NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; TypeFlags[TypeFlags["String"] = 2] = "String"; @@ -673,14 +688,16 @@ var ts; TypeFlags[TypeFlags["Object"] = 32768] = "Object"; TypeFlags[TypeFlags["Union"] = 65536] = "Union"; TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 262144] = "FreshLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 1048576] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 2097152] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -698,17 +715,17 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 245760] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 246783] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; @@ -720,19 +737,19 @@ var ts; ObjectFlags[ObjectFlags["EvolvingArray"] = 128] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 256] = "ObjectLiteralPatternWithComputedProperties"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; - })(ts.ObjectFlags || (ts.ObjectFlags = {})); - var ObjectFlags = ts.ObjectFlags; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); /* @internal */ + var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; /// exports.name = expr @@ -743,19 +760,19 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; /// this.name = expr SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; + })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var ModuleResolutionKind; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; + })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -763,53 +780,54 @@ var ts; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; + })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; (function (JsxEmit) { JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; - })(ts.JsxEmit || (ts.JsxEmit = {})); - var JsxEmit = ts.JsxEmit; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; (function (NewLineKind) { NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; (function (ScriptKind) { ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; ScriptKind[ScriptKind["JS"] = 1] = "JS"; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; - })(ts.ScriptKind || (ts.ScriptKind = {})); - var ScriptKind = ts.ScriptKind; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; - ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; - })(ts.ScriptTarget || (ts.ScriptTarget = {})); - var ScriptTarget = ts.ScriptTarget; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; (function (LanguageVariant) { LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); /* @internal */ + var DiagnosticStyle; (function (DiagnosticStyle) { DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; (function (WatchDirectoryFlags) { WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); /* @internal */ + var CharacterCodes; (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -936,9 +954,18 @@ var ts; CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ + var TransformFlags; (function (TransformFlags) { TransformFlags[TransformFlags["None"] = 0] = "None"; // Facts @@ -947,61 +974,66 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; - TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; - TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; - TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ESNext"] = 16] = "ESNext"; + TransformFlags[TransformFlags["ContainsESNext"] = 32] = "ContainsESNext"; + TransformFlags[TransformFlags["ES2017"] = 64] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 256] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 512] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 1024] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 2048] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 4096] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 8192] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 16384] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 32768] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 65536] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 131072] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 262144] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 524288] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 1048576] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 2097152] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 4194304] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadExpression"] = 8388608] = "ContainsSpreadExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 16777216] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 33554432] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 67108864] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 134217728] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 268435456] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertESNext"] = 48] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 192] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 768] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 3072] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 12288] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 49152] = "AssertDestructuringAssignment"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536892757] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 979719509] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 980243797] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 975983957] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 975983957] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 559895893] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 839734613] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 554784085] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 545281365] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 604001621] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 604001621] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 4390912] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 2621440] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); /* @internal */ + var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; @@ -1030,16 +1062,17 @@ var ts; EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; + EmitFlags[EmitFlags["NoHoisting"] = 16777216] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 33554432] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /* @internal */ + var EmitContext; (function (EmitContext) { EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; EmitContext[EmitContext["Expression"] = 1] = "Expression"; EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(ts.EmitContext || (ts.EmitContext = {})); - var EmitContext = ts.EmitContext; + })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1149,12 +1182,12 @@ var ts; * 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. */ + var Ternary; (function (Ternary) { Ternary[Ternary["False"] = 0] = "False"; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; - })(ts.Ternary || (ts.Ternary = {})); - var Ternary = ts.Ternary; + })(Ternary = ts.Ternary || (ts.Ternary = {})); var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -1226,12 +1259,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; - })(ts.Comparison || (ts.Comparison = {})); - var Comparison = ts.Comparison; + })(Comparison = ts.Comparison || (ts.Comparison = {})); /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -1249,6 +1282,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; /** * Iterates through `array` by index and performs the callback on each element of array until the callback * returns a falsey value, then returns false. @@ -1541,20 +1581,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -1634,6 +1679,31 @@ var ts; return result || array; } ts.compact = compact; + /** + * Gets the relative complement of `arrayA` with respect to `b`, returning the elements that + * are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted + * based on the provided comparer. + */ + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1 /* LessThan */: break inner; + case 0 /* EqualTo */: continue outer; + case 1 /* GreaterThan */: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -1643,15 +1713,39 @@ var ts; return result; } ts.sum = sum; + /** + * Appends a value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param value The value to append to the array. If `value` is `undefined`, nothing is + * appended. + */ + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; + /** + * Appends a range of value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + */ function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -1664,26 +1758,17 @@ var ts; return true; } ts.rangeEquals = rangeEquals; + /** + * Returns the first element of an array if non-empty, `undefined` otherwise. + */ function firstOrUndefined(array) { return array && array.length > 0 ? array[0] : undefined; } ts.firstOrUndefined = firstOrUndefined; - function singleOrUndefined(array) { - return array && array.length === 1 - ? array[0] - : undefined; - } - ts.singleOrUndefined = singleOrUndefined; - function singleOrMany(array) { - return array && array.length === 1 - ? array[0] - : array; - } - ts.singleOrMany = singleOrMany; /** - * Returns the last element of an array if non-empty, undefined otherwise. + * Returns the last element of an array if non-empty, `undefined` otherwise. */ function lastOrUndefined(array) { return array && array.length > 0 @@ -1691,6 +1776,25 @@ var ts; : undefined; } ts.lastOrUndefined = lastOrUndefined; + /** + * Returns the only element of an array if it contains only one element, `undefined` otherwise. + */ + function singleOrUndefined(array) { + return array && array.length === 1 + ? array[0] + : undefined; + } + ts.singleOrUndefined = singleOrUndefined; + /** + * Returns the only element of an array if it contains only one element; otheriwse, returns the + * array. + */ + function singleOrMany(array) { + return array && array.length === 1 + ? array[0] + : array; + } + ts.singleOrMany = singleOrMany; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; @@ -1704,11 +1808,11 @@ var ts; * @param array A sorted array whose first element must be no larger than number * @param number The value to be searched for in the array. */ - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -2606,6 +2710,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -2646,73 +2754,93 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - // getNormalizedPathComponents includes the separator for the root component. - // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - // The * and ? wildcards should not match directories or files that start with . if they - // appear first in a component. Dotted directories and files can be included explicitly - // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63 /* question */) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + /** + * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, + * and does not contain any glob characters itself. + */ + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + // getNormalizedPathComponents includes the separator for the root component. + // We need to remove to create our regex correctly. + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + // The * and ? wildcards should not match directories or files that start with . if they + // appear first in a component. Dotted directories and files can be included explicitly + // like so: **/.*/.* + if (component.charCodeAt(0) === 42 /* asterisk */) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63 /* question */) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -2786,29 +2914,35 @@ var ts; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); // Append the literal and canonical candidate base paths. - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); + } + }; // Iterate over each include base path and include unique base paths that are not a // subpath of an existing base path - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } - } - basePaths.push(includeBasePath); + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + // No "*" or "?" in the path + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { // Using scriptKind as a condition handles both: // - 'scriptKind' is unspecified and thus it is `undefined` @@ -2873,14 +3007,14 @@ var ts; * aligned to the offset of the highest priority extension in the * allSupportedExtensions array. */ + var ExtensionPriority; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; - })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); - var ExtensionPriority = ts.ExtensionPriority; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2939,10 +3073,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -2977,13 +3107,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; (function (AssertionLevel) { AssertionLevel[AssertionLevel["None"] = 0] = "None"; AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(ts.AssertionLevel || (ts.AssertionLevel = {})); - var AssertionLevel = ts.AssertionLevel; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0 /* None */; @@ -3120,6 +3250,35 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + /** True if an extension is one of the supported TypeScript extensions. */ + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + /** + * Gets the extension from a path. + * Path must have a valid extension. + */ + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); /// var ts; @@ -3441,6 +3600,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -3450,7 +3610,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -3458,7 +3618,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -3475,7 +3635,7 @@ var ts; // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -3684,7 +3844,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -3911,14 +4071,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -3958,7 +4118,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -3996,8 +4156,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -4009,7 +4167,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -4031,9 +4189,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -4080,6 +4236,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4103,6 +4266,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -4134,6 +4298,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4233,6 +4400,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -4316,7 +4484,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4353,11 +4521,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4366,7 +4539,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -4423,6 +4597,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); /// @@ -4458,7 +4633,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 137 /* FromKeyword */, + "from": 138 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4468,34 +4643,35 @@ var ts; "instanceof": 92 /* InstanceOfKeyword */, "interface": 108 /* InterfaceKeyword */, "is": 125 /* IsKeyword */, + "keyof": 126 /* KeyOfKeyword */, "let": 109 /* LetKeyword */, - "module": 126 /* ModuleKeyword */, - "namespace": 127 /* NamespaceKeyword */, - "never": 128 /* NeverKeyword */, + "module": 127 /* ModuleKeyword */, + "namespace": 128 /* NamespaceKeyword */, + "never": 129 /* NeverKeyword */, "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, - "number": 131 /* NumberKeyword */, + "number": 132 /* NumberKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, - "readonly": 129 /* ReadonlyKeyword */, - "require": 130 /* RequireKeyword */, - "global": 138 /* GlobalKeyword */, + "readonly": 130 /* ReadonlyKeyword */, + "require": 131 /* RequireKeyword */, + "global": 139 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 132 /* SetKeyword */, + "set": 133 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 133 /* StringKeyword */, + "string": 134 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 134 /* SymbolKeyword */, + "symbol": 135 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 135 /* TypeKeyword */, + "type": 136 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 136 /* UndefinedKeyword */, + "undefined": 137 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4503,7 +4679,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 139 /* OfKeyword */, + "of": 140 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -6057,9 +6233,9 @@ var ts; pos++; return token = 22 /* DotToken */; } - if (isIdentifierStart(ch, 4 /* Latest */)) { + if (isIdentifierStart(ch, 5 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5 /* Latest */) && pos < end) { pos++; } return token = 70 /* Identifier */; @@ -6227,7 +6403,9 @@ var ts; ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; /* @internal */ @@ -6256,28 +6434,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 2097152 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 4194304 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 4194304 /* HasAggregatedChildData */)) { + if (!(node.flags & 8388608 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 4194304 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 4194304 /* HasAggregatedChildData */; + node.flags |= 8388608 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 256 /* SourceFile */) { + while (node && node.kind !== 260 /* SourceFile */) { node = node.parent; } return node; @@ -6285,11 +6463,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: return true; } return false; @@ -6380,18 +6558,18 @@ 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 === 286 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 290 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 257 /* FirstJSDocNode */ && node.kind <= 282 /* LastJSDocNode */; + return node.kind >= 261 /* FirstJSDocNode */ && node.kind <= 286 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; + return node.kind >= 277 /* FirstJSDocTagNode */ && node.kind <= 289 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6495,25 +6673,26 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 219 /* VariableDeclaration */ && node.parent.kind === 252 /* CatchClause */; + return node.kind === 222 /* VariableDeclaration */ && node.parent.kind === 255 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 /* ModuleDeclaration */ && + return node && node.kind === 229 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ function isShorthandAmbientModuleSymbol(moduleSymbol) { return isShorthandAmbientModule(moduleSymbol.valueDeclaration); } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 226 /* ModuleDeclaration */ && (!node.body); + return node.kind === 229 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 /* SourceFile */ || - node.kind === 226 /* ModuleDeclaration */ || + return node.kind === 260 /* SourceFile */ || + node.kind === 229 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6529,9 +6708,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: return ts.isExternalModule(node.parent); - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6539,22 +6718,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 252 /* CatchClause */: - case 226 /* ModuleDeclaration */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 260 /* SourceFile */: + case 231 /* CaseBlock */: + case 255 /* CatchClause */: + case 229 /* ModuleDeclaration */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return true; - case 200 /* Block */: + case 203 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6581,12 +6760,42 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70 /* Identifier */: + return name.text; + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + return name.text; + case 142 /* ComputedPropertyName */: + if (isStringOrNumericLiteral(name.expression.kind)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70 /* Identifier */: + return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); + case 141 /* QualifiedName */: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 176 /* PropertyAccessExpression */: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { var span = getErrorSpanForNode(sourceFile, node); return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } - ts.createDiagnosticForNode = createDiagnosticForNode; + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -6609,7 +6818,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200 /* Block */) { + if (node.body && node.body.kind === 203 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6623,7 +6832,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* 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 @@ -6632,23 +6841,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 224 /* TypeAliasDeclaration */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 227 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6671,7 +6880,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 /* EnumDeclaration */ && isConst(node); + return node.kind === 228 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6684,11 +6893,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 178 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 206 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6704,10 +6913,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 /* Parameter */ || - node.kind === 142 /* TypeParameter */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 181 /* ArrowFunction */) ? + var commentRanges = (node.kind === 144 /* Parameter */ || + node.kind === 143 /* TypeParameter */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 184 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6723,39 +6932,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { + if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 170 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 135 /* SymbolKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 184 /* VoidExpression */; - case 195 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 187 /* VoidExpression */; + case 198 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 176 /* 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 === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 140 /* QualifiedName */: - case 173 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 176 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 159 /* TypeQuery */) { + if (parent_1.kind === 160 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6764,38 +6973,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { + if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 170 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return node === parent_1.constraint; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 143 /* Parameter */: - case 219 /* VariableDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 144 /* Parameter */: + case 222 /* VariableDeclaration */: return node === parent_1.type; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return node === parent_1.type; - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return node === parent_1.type; - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return node === parent_1.type; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6809,23 +7018,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitor(node); - case 228 /* CaseBlock */: - case 200 /* Block */: - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 213 /* WithStatement */: - case 214 /* SwitchStatement */: - case 249 /* CaseClause */: - case 250 /* DefaultClause */: - case 215 /* LabeledStatement */: - case 217 /* TryStatement */: - case 252 /* CatchClause */: + case 231 /* CaseBlock */: + case 203 /* Block */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 216 /* WithStatement */: + case 217 /* SwitchStatement */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: + case 218 /* LabeledStatement */: + case 220 /* TryStatement */: + case 255 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -6835,18 +7044,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225 /* EnumDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -6854,7 +7063,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 141 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 142 /* 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(name_5.expression); @@ -6873,14 +7082,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170 /* BindingElement */: - case 255 /* EnumMember */: - case 143 /* Parameter */: - case 253 /* PropertyAssignment */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 254 /* ShorthandPropertyAssignment */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 259 /* EnumMember */: + case 144 /* Parameter */: + case 256 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* ShorthandPropertyAssignment */: + case 222 /* VariableDeclaration */: return true; } } @@ -6888,11 +7097,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); + return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); + return node && (node.kind === 225 /* ClassDeclaration */ || node.kind === 196 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6901,19 +7110,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return true; } return false; @@ -6921,13 +7130,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return true; } return false; @@ -6935,30 +7144,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: return true; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 203 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; + return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 175 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 /* MethodDeclaration */ && - (node.parent.kind === 172 /* ObjectLiteralExpression */ || - node.parent.kind === 193 /* ClassExpression */); + return node.kind === 149 /* MethodDeclaration */ && + (node.parent.kind === 175 /* ObjectLiteralExpression */ || + node.parent.kind === 196 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6994,7 +7203,7 @@ var ts; return undefined; } switch (node.kind) { - case 141 /* ComputedPropertyName */: + case 142 /* 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 @@ -7009,9 +7218,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 144 /* Parameter */ && 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; @@ -7022,26 +7231,26 @@ var ts; node = node.parent; } break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 226 /* ModuleDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 225 /* EnumDeclaration */: - case 256 /* SourceFile */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 229 /* ModuleDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 228 /* EnumDeclaration */: + case 260 /* SourceFile */: return node; } } @@ -7062,26 +7271,26 @@ var ts; return node; } switch (node.kind) { - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: node = node.parent; break; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return node; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 144 /* Parameter */ && 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; @@ -7097,14 +7306,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { + if (func.kind === 183 /* FunctionExpression */ || func.kind === 184 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179 /* ParenthesizedExpression */) { + while (parent_2.kind === 182 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 178 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7115,32 +7324,32 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + return (kind === 176 /* PropertyAccessExpression */ || kind === 177 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 156 /* TypeReference */: - return node.typeName; - case 195 /* ExpressionWithTypeArguments */: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 70 /* Identifier */: - case 140 /* QualifiedName */: - return node; - } + switch (node.kind) { + case 157 /* TypeReference */: + case 271 /* JSDocTypeReference */: + return node.typeName; + case 198 /* ExpressionWithTypeArguments */: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70 /* Identifier */: + case 141 /* QualifiedName */: + return node; } return undefined; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 177 /* TaggedTemplateExpression */: - case 144 /* Decorator */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 180 /* TaggedTemplateExpression */: + case 145 /* Decorator */: return true; default: return false; @@ -7148,7 +7357,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7157,25 +7366,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: // classes are valid targets return true; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 222 /* ClassDeclaration */; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: + return node.parent.kind === 225 /* ClassDeclaration */; + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 222 /* ClassDeclaration */; - case 143 /* Parameter */: + && node.parent.kind === 225 /* ClassDeclaration */; + case 144 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 149 /* Constructor */ - || node.parent.kind === 148 /* MethodDeclaration */ - || node.parent.kind === 151 /* SetAccessor */) - && node.parent.parent.kind === 222 /* ClassDeclaration */; + && (node.parent.kind === 150 /* Constructor */ + || node.parent.kind === 149 /* MethodDeclaration */ + || node.parent.kind === 152 /* SetAccessor */) + && node.parent.parent.kind === 225 /* ClassDeclaration */; } return false; } @@ -7191,19 +7400,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148 /* MethodDeclaration */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 152 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 244 /* JsxOpeningElement */ || - parent.kind === 243 /* JsxSelfClosingElement */ || - parent.kind === 245 /* JsxClosingElement */) { + if (parent.kind === 247 /* JsxOpeningElement */ || + parent.kind === 246 /* JsxSelfClosingElement */ || + parent.kind === 248 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7217,43 +7426,43 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 177 /* TaggedTemplateExpression */: - case 196 /* AsExpression */: - case 178 /* TypeAssertionExpression */: - case 197 /* NonNullExpression */: - case 179 /* ParenthesizedExpression */: - case 180 /* FunctionExpression */: - case 193 /* ClassExpression */: - case 181 /* ArrowFunction */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 183 /* TypeOfExpression */: - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: - case 188 /* BinaryExpression */: - case 189 /* ConditionalExpression */: - case 192 /* SpreadElementExpression */: - case 190 /* TemplateExpression */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 180 /* TaggedTemplateExpression */: + case 199 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 200 /* NonNullExpression */: + case 182 /* ParenthesizedExpression */: + case 183 /* FunctionExpression */: + case 196 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 186 /* TypeOfExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + case 191 /* BinaryExpression */: + case 192 /* ConditionalExpression */: + case 195 /* SpreadElement */: + case 193 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* OmittedExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 191 /* YieldExpression */: - case 185 /* AwaitExpression */: + case 197 /* OmittedExpression */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: + case 194 /* YieldExpression */: + case 188 /* AwaitExpression */: return true; - case 140 /* QualifiedName */: - while (node.parent.kind === 140 /* QualifiedName */) { + case 141 /* QualifiedName */: + while (node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through @@ -7262,47 +7471,47 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 219 /* VariableDeclaration */: - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 255 /* EnumMember */: - case 253 /* PropertyAssignment */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 259 /* EnumMember */: + case 256 /* PropertyAssignment */: + case 173 /* BindingElement */: return parent_3.initializer === node; - case 203 /* ExpressionStatement */: - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 212 /* ReturnStatement */: - case 213 /* WithStatement */: - case 214 /* SwitchStatement */: - case 249 /* CaseClause */: - case 216 /* ThrowStatement */: - case 214 /* SwitchStatement */: + case 206 /* ExpressionStatement */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 215 /* ReturnStatement */: + case 216 /* WithStatement */: + case 217 /* SwitchStatement */: + case 252 /* CaseClause */: + case 219 /* ThrowStatement */: + case 217 /* SwitchStatement */: return parent_3.expression === node; - case 207 /* ForStatement */: + case 210 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 223 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 223 /* VariableDeclarationList */) || forInStatement.expression === node; - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return node === parent_3.expression; - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return node === parent_3.expression; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return node === parent_3.expression; - case 144 /* Decorator */: - case 248 /* JsxExpression */: - case 247 /* JsxSpreadAttribute */: + case 145 /* Decorator */: + case 251 /* JsxExpression */: + case 250 /* JsxSpreadAttribute */: return true; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7320,7 +7529,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; + return node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 244 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7329,7 +7538,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; + return node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 244 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7337,7 +7546,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576 /* JavaScriptFile */); + return node && !!(node.flags & 2097152 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7347,7 +7556,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 175 /* CallExpression */ && + var isRequire = expression.kind === 178 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7363,9 +7572,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 222 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 183 /* FunctionExpression */; } return false; } @@ -7376,11 +7585,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 188 /* BinaryExpression */) { + if (expression.kind !== 191 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 176 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7398,7 +7607,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 176 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7416,35 +7625,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 234 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 241 /* ExternalModuleReference */) { + if (reference.kind === 244 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 237 /* ExportDeclaration */) { + if (node.kind === 240 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 229 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 236 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 /* ImportDeclaration */ + return node.kind === 234 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7452,13 +7661,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143 /* Parameter */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 254 /* ShorthandPropertyAssignment */: - case 253 /* PropertyAssignment */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 257 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7466,9 +7675,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 /* JSDocFunctionType */ && + return node.kind === 273 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 271 /* JSDocConstructorType */; + node.parameters[0].type.kind === 275 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7528,34 +7737,34 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.parent.kind === 204 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.kind === 204 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 226 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 229 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 188 /* BinaryExpression */ && + parent_4.kind === 191 /* BinaryExpression */ && parent_4.operatorToken.kind === 57 /* EqualsToken */ && - parent_4.parent.kind === 203 /* ExpressionStatement */; + parent_4.parent.kind === 206 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 253 /* PropertyAssignment */; + var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 256 /* PropertyAssignment */; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7581,14 +7790,14 @@ var ts; if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -7600,15 +7809,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 281 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); + return getJSDocTag(node, 280 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 282 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -7622,7 +7831,7 @@ var ts; } for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { var tag = jsDocTags_2[_i]; - if (tag.kind === 275 /* JSDocParameterTag */) { + if (tag.kind === 279 /* JSDocParameterTag */) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -7642,13 +7851,13 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 1048576 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 270 /* JSDocVariadicType */) { + if (node && (node.flags & 2097152 /* JavaScriptFile */)) { + if (node.type && node.type.kind === 274 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocVariadicType */; } } return isDeclaredRestParam(node); @@ -7658,29 +7867,53 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 191 /* BinaryExpression */: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + 0 /* None */; + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + var unaryOperator = parent.operator; + return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; + case 182 /* ParenthesizedExpression */: + case 174 /* ArrayLiteralExpression */: + case 195 /* SpreadElement */: + node = parent; + break; + case 257 /* ShorthandPropertyAssignment */: + if (parent.name !== node) { + return 0 /* None */; + } + // Fall through + case 256 /* PropertyAssignment */: + node = parent.parent; + break; + default: + return 0 /* None */; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 179 /* ParenthesizedExpression */) { - node = node.parent; - } - while (true) { - var parent_5 = node.parent; - if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { - node = parent_5; - continue; - } - if (parent_5.kind === 253 /* PropertyAssignment */ || parent_5.kind === 254 /* ShorthandPropertyAssignment */) { - node = parent_5.parent; - continue; - } - return parent_5.kind === 188 /* BinaryExpression */ && - isAssignmentOperator(parent_5.operatorToken.kind) && - parent_5.left === node || - (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && - parent_5.initializer === node; - } + return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; function isNodeDescendantOf(node, ancestor) { @@ -7694,7 +7927,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 256 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 260 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7708,7 +7941,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { + if (parent.kind === 238 /* ImportSpecifier */ || parent.kind === 242 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7721,7 +7954,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 141 /* ComputedPropertyName */ && + node.parent.kind === 142 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7729,31 +7962,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 255 /* EnumMember */: - case 253 /* PropertyAssignment */: - case 173 /* PropertyAccessExpression */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 259 /* EnumMember */: + case 256 /* PropertyAssignment */: + case 176 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 140 /* QualifiedName */) { + while (parent.kind === 141 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 159 /* TypeQuery */; + return parent.kind === 160 /* TypeQuery */; } return false; - case 170 /* BindingElement */: - case 235 /* ImportSpecifier */: + case 173 /* BindingElement */: + case 238 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7769,13 +8002,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ || - node.kind === 229 /* NamespaceExportDeclaration */ || - node.kind === 232 /* ImportClause */ && !!node.name || - node.kind === 233 /* NamespaceImport */ || - node.kind === 235 /* ImportSpecifier */ || - node.kind === 239 /* ExportSpecifier */ || - node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 233 /* ImportEqualsDeclaration */ || + node.kind === 232 /* NamespaceExportDeclaration */ || + node.kind === 235 /* ImportClause */ && !!node.name || + node.kind === 236 /* NamespaceImport */ || + node.kind === 238 /* ImportSpecifier */ || + node.kind === 242 /* ExportSpecifier */ || + node.kind === 239 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7861,7 +8094,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7888,7 +8121,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 /* ComputedPropertyName */ && + return name.kind === 142 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7903,10 +8136,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { return name.text; } - if (name.kind === 141 /* ComputedPropertyName */) { + if (name.kind === 142 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7945,7 +8178,7 @@ var ts; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: case 114 /* StaticKeyword */: return true; } @@ -7954,11 +8187,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 143 /* Parameter */; + return root.kind === 144 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 170 /* BindingElement */) { + while (node.kind === 173 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7966,15 +8199,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 149 /* Constructor */ - || kind === 180 /* FunctionExpression */ - || kind === 221 /* FunctionDeclaration */ - || kind === 181 /* ArrowFunction */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 226 /* ModuleDeclaration */ - || kind === 256 /* SourceFile */; + return kind === 150 /* Constructor */ + || kind === 183 /* FunctionExpression */ + || kind === 224 /* FunctionDeclaration */ + || kind === 184 /* ArrowFunction */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 229 /* ModuleDeclaration */ + || kind === 260 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -7982,13 +8215,13 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { + function getOriginalNode(node, nodeTest) { if (node) { while (node.original !== undefined) { node = node.original; } } - return node; + return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; /** @@ -8028,30 +8261,30 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; Associativity[Associativity["Right"] = 1] = "Right"; - })(ts.Associativity || (ts.Associativity = {})); - var Associativity = ts.Associativity; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176 /* NewExpression */: + case 179 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: - case 189 /* ConditionalExpression */: - case 191 /* YieldExpression */: + case 189 /* PrefixUnaryExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 188 /* AwaitExpression */: + case 192 /* ConditionalExpression */: + case 194 /* YieldExpression */: return 1 /* Right */; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8075,15 +8308,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188 /* BinaryExpression */) { + if (expression.kind === 191 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { + else if (expression.kind === 189 /* PrefixUnaryExpression */ || expression.kind === 190 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8101,36 +8334,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 196 /* ClassExpression */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 190 /* TemplateExpression */: - case 179 /* ParenthesizedExpression */: - case 194 /* OmittedExpression */: + case 193 /* TemplateExpression */: + case 182 /* ParenthesizedExpression */: + case 197 /* OmittedExpression */: return 19; - case 177 /* TaggedTemplateExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 180 /* TaggedTemplateExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: return 18; - case 176 /* NewExpression */: + case 179 /* NewExpression */: return hasArguments ? 18 : 17; - case 175 /* CallExpression */: + case 178 /* CallExpression */: return 17; - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return 16; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: + case 189 /* PrefixUnaryExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 188 /* AwaitExpression */: return 15; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8188,11 +8421,11 @@ var ts; default: return -1; } - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return 4; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return 2; - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return 1; default: return -1; @@ -8462,14 +8695,17 @@ var ts; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); + var sourceFiles = getAllEmittableSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; return ts.filter(sourceFiles, isNonDeclarationFile); } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } } ts.getSourceFilesToEmit = getSourceFilesToEmit; function isNonDeclarationFile(sourceFile) { @@ -8554,7 +8790,7 @@ var ts; onBundledEmit(host); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; // Don't emit if source file is a declaration file, or was located under node_modules @@ -8591,7 +8827,7 @@ var ts; function onBundledEmit(host) { // Can emit only sources that are not declaration file and are either non module code or module with // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || !!ts.getEmitModuleKind(options)); }); @@ -8631,7 +8867,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8673,10 +8909,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 150 /* GetAccessor */) { + if (accessor.kind === 151 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 151 /* SetAccessor */) { + else if (accessor.kind === 152 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8685,7 +8921,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) + if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8696,10 +8932,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 150 /* GetAccessor */ && !getAccessor) { + if (member.kind === 151 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 151 /* SetAccessor */ && !setAccessor) { + if (member.kind === 152 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8945,7 +9181,7 @@ var ts; case 75 /* ConstKeyword */: return 2048 /* Const */; case 78 /* DefaultKeyword */: return 512 /* Default */; case 119 /* AsyncKeyword */: return 256 /* Async */; - case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 130 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } @@ -8962,19 +9198,25 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ && + if (node.kind === 198 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node) { + return isBinaryExpression(node) + && isAssignmentOperator(node.operatorToken.kind) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 172 /* ObjectLiteralExpression */ - || kind === 171 /* ArrayLiteralExpression */; + return kind === 175 /* ObjectLiteralExpression */ + || kind === 174 /* ArrayLiteralExpression */; } } return false; @@ -9003,20 +9245,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 176 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172 /* ObjectLiteralExpression */) { + if (kind === 175 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 171 /* ArrayLiteralExpression */) { + if (kind === 174 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9178,39 +9420,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 173 /* PropertyAccessExpression */) { + else if (kind === 176 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174 /* ElementAccessExpression */) { + else if (kind === 177 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */) { + else if (kind === 189 /* PrefixUnaryExpression */ + || kind === 190 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188 /* BinaryExpression */) { + else if (kind === 191 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189 /* ConditionalExpression */) { + else if (kind === 192 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 184 /* VoidExpression */ - || kind === 183 /* TypeOfExpression */ - || kind === 182 /* DeleteExpression */) { + else if (kind === 187 /* VoidExpression */ + || kind === 186 /* TypeOfExpression */ + || kind === 185 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171 /* ArrayLiteralExpression */) { + else if (kind === 174 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 172 /* ObjectLiteralExpression */) { + else if (kind === 175 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 175 /* CallExpression */) { + else if (kind === 178 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9369,28 +9611,31 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile, resolver) { var externalImports = []; var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 230 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + case 233 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 244 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -9406,22 +9651,111 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_8 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_8] || (exportSpecifiers[name_8] = [])).push(specifier); + if (!uniqueExports[specifier.name.text]) { + var name_8 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_8.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_8) + || resolver.getReferencedValueDeclaration(name_8); + if (decl) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = specifier.name; + } } } break; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; + case 204 /* VariableStatement */: + if (hasModifier(node, 1 /* Export */)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + collectExportedVariableInfo(decl, uniqueExports); + } + } + break; + case 224 /* FunctionDeclaration */: + if (hasModifier(node, 1 /* Export */)) { + if (hasModifier(node, 512 /* Default */)) { + // export default function() { } + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + // export function x() { } + var name_9 = node.name; + if (!uniqueExports[name_9.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_9); + uniqueExports[name_9.text] = name_9; + } + } + } + break; + case 225 /* ClassDeclaration */: + if (hasModifier(node, 1 /* Export */)) { + if (hasModifier(node, 512 /* Default */)) { + // export default class { } + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + // export class x { } + var name_10 = node.name; + if (!uniqueExports[name_10.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_10); + uniqueExports[name_10.text] = name_10; + } + } + } + break; } } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + var exportedNames; + for (var key in uniqueExports) { + exportedNames = ts.append(exportedNames, uniqueExports[key]); + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; } ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports) { + if (isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!isOmittedExpression(element)) { + collectExportedVariableInfo(element, uniqueExports); + } + } + } + else if (!isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = decl.name; + } + } + } + /** + * Determines whether a name was originally the declaration name of an enum or namespace + * declaration. + */ + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9436,7 +9770,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 225 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9513,16 +9847,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 140 /* QualifiedName */; + return node.kind === 141 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 141 /* ComputedPropertyName */; + return node.kind === 142 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 140 /* QualifiedName */ + return kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9531,7 +9865,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 141 /* ComputedPropertyName */; + || kind === 142 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9543,60 +9877,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 168 /* ObjectBindingPattern */ - || kind === 169 /* ArrayBindingPattern */; + || kind === 171 /* ObjectBindingPattern */ + || kind === 172 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 142 /* TypeParameter */; + return node.kind === 143 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 143 /* Parameter */; + return node.kind === 144 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 144 /* Decorator */; + return node.kind === 145 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 148 /* MethodDeclaration */; + return node.kind === 149 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 149 /* Constructor */ - || kind === 146 /* PropertyDeclaration */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 154 /* IndexSignature */ - || kind === 199 /* SemicolonClassElement */; + return kind === 150 /* Constructor */ + || kind === 147 /* PropertyDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 155 /* IndexSignature */ + || kind === 202 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 /* PropertyAssignment */ - || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 240 /* MissingDeclaration */; + return kind === 256 /* PropertyAssignment */ + || kind === 257 /* ShorthandPropertyAssignment */ + || kind === 258 /* SpreadAssignment */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 243 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + return (kind >= 156 /* FirstTypeNode */ && kind <= 170 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ - || kind === 131 /* NumberKeyword */ + || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 133 /* StringKeyword */ - || kind === 134 /* SymbolKeyword */ + || kind === 134 /* StringKeyword */ + || kind === 135 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ - || kind === 128 /* NeverKeyword */ - || kind === 195 /* ExpressionWithTypeArguments */; + || kind === 129 /* NeverKeyword */ + || kind === 198 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9611,95 +9946,103 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 /* ArrayBindingPattern */ - || kind === 168 /* ObjectBindingPattern */; + return kind === 172 /* ArrayBindingPattern */ + || kind === 171 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170 /* BindingElement */; + return node.kind === 173 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 /* BindingElement */ - || kind === 194 /* OmittedExpression */; + return kind === 173 /* BindingElement */ + || kind === 197 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression + function isArrayLiteralExpression(node) { + return node.kind === 174 /* ArrayLiteralExpression */; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 175 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173 /* PropertyAccessExpression */; + return node.kind === 176 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174 /* ElementAccessExpression */; + return node.kind === 177 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188 /* BinaryExpression */; + return node.kind === 191 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189 /* ConditionalExpression */; + return node.kind === 192 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175 /* CallExpression */; + return node.kind === 178 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 /* TemplateExpression */ + return kind === 193 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192 /* SpreadElementExpression */; + function isSpreadExpression(node) { + return node.kind === 195 /* SpreadElement */; } - ts.isSpreadElementExpression = isSpreadElementExpression; + ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 195 /* ExpressionWithTypeArguments */; + return node.kind === 198 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 /* PropertyAccessExpression */ - || kind === 174 /* ElementAccessExpression */ - || kind === 176 /* NewExpression */ - || kind === 175 /* CallExpression */ - || kind === 242 /* JsxElement */ - || kind === 243 /* JsxSelfClosingElement */ - || kind === 177 /* TaggedTemplateExpression */ - || kind === 171 /* ArrayLiteralExpression */ - || kind === 179 /* ParenthesizedExpression */ - || kind === 172 /* ObjectLiteralExpression */ - || kind === 193 /* ClassExpression */ - || kind === 180 /* FunctionExpression */ + return kind === 176 /* PropertyAccessExpression */ + || kind === 177 /* ElementAccessExpression */ + || kind === 179 /* NewExpression */ + || kind === 178 /* CallExpression */ + || kind === 245 /* JsxElement */ + || kind === 246 /* JsxSelfClosingElement */ + || kind === 180 /* TaggedTemplateExpression */ + || kind === 174 /* ArrayLiteralExpression */ + || kind === 182 /* ParenthesizedExpression */ + || kind === 175 /* ObjectLiteralExpression */ + || kind === 196 /* ClassExpression */ + || kind === 183 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 190 /* TemplateExpression */ + || kind === 193 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 197 /* NonNullExpression */; + || kind === 200 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */ - || kind === 182 /* DeleteExpression */ - || kind === 183 /* TypeOfExpression */ - || kind === 184 /* VoidExpression */ - || kind === 185 /* AwaitExpression */ - || kind === 178 /* TypeAssertionExpression */ + return kind === 189 /* PrefixUnaryExpression */ + || kind === 190 /* PostfixUnaryExpression */ + || kind === 185 /* DeleteExpression */ + || kind === 186 /* TypeOfExpression */ + || kind === 187 /* VoidExpression */ + || kind === 188 /* AwaitExpression */ + || kind === 181 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9707,13 +10050,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 /* ConditionalExpression */ - || kind === 191 /* YieldExpression */ - || kind === 181 /* ArrowFunction */ - || kind === 188 /* BinaryExpression */ - || kind === 192 /* SpreadElementExpression */ - || kind === 196 /* AsExpression */ - || kind === 194 /* OmittedExpression */ + return kind === 192 /* ConditionalExpression */ + || kind === 194 /* YieldExpression */ + || kind === 184 /* ArrowFunction */ + || kind === 191 /* BinaryExpression */ + || kind === 195 /* SpreadElement */ + || kind === 199 /* AsExpression */ + || kind === 197 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9722,16 +10065,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 /* TypeAssertionExpression */ - || kind === 196 /* AsExpression */; + return kind === 181 /* TypeAssertionExpression */ + || kind === 199 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288 /* PartiallyEmittedExpression */; + return node.kind === 292 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287 /* NotEmittedStatement */; + return node.kind === 291 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9740,17 +10083,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194 /* OmittedExpression */; + return node.kind === 197 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 198 /* TemplateSpan */; + return node.kind === 201 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 200 /* Block */; + return node.kind === 203 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9768,119 +10111,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219 /* VariableDeclaration */; + return node.kind === 222 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220 /* VariableDeclarationList */; + return node.kind === 223 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228 /* CaseBlock */; + return node.kind === 231 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 /* ModuleBlock */ - || kind === 226 /* ModuleDeclaration */; + return kind === 230 /* ModuleBlock */ + || kind === 229 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */; + return node.kind === 233 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232 /* ImportClause */; + return node.kind === 235 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 /* NamedImports */ - || kind === 233 /* NamespaceImport */; + return kind === 237 /* NamedImports */ + || kind === 236 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235 /* ImportSpecifier */; + return node.kind === 238 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238 /* NamedExports */; + return node.kind === 241 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239 /* ExportSpecifier */; + return node.kind === 242 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; + return node.kind === 229 /* ModuleDeclaration */ || node.kind === 228 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 /* ArrowFunction */ - || kind === 170 /* BindingElement */ - || kind === 222 /* ClassDeclaration */ - || kind === 193 /* ClassExpression */ - || kind === 149 /* Constructor */ - || kind === 225 /* EnumDeclaration */ - || kind === 255 /* EnumMember */ - || kind === 239 /* ExportSpecifier */ - || kind === 221 /* FunctionDeclaration */ - || kind === 180 /* FunctionExpression */ - || kind === 150 /* GetAccessor */ - || kind === 232 /* ImportClause */ - || kind === 230 /* ImportEqualsDeclaration */ - || kind === 235 /* ImportSpecifier */ - || kind === 223 /* InterfaceDeclaration */ - || kind === 148 /* MethodDeclaration */ - || kind === 147 /* MethodSignature */ - || kind === 226 /* ModuleDeclaration */ - || kind === 229 /* NamespaceExportDeclaration */ - || kind === 233 /* NamespaceImport */ - || kind === 143 /* Parameter */ - || kind === 253 /* PropertyAssignment */ - || kind === 146 /* PropertyDeclaration */ - || kind === 145 /* PropertySignature */ - || kind === 151 /* SetAccessor */ - || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 224 /* TypeAliasDeclaration */ - || kind === 142 /* TypeParameter */ - || kind === 219 /* VariableDeclaration */ - || kind === 279 /* JSDocTypedefTag */; + return kind === 184 /* ArrowFunction */ + || kind === 173 /* BindingElement */ + || kind === 225 /* ClassDeclaration */ + || kind === 196 /* ClassExpression */ + || kind === 150 /* Constructor */ + || kind === 228 /* EnumDeclaration */ + || kind === 259 /* EnumMember */ + || kind === 242 /* ExportSpecifier */ + || kind === 224 /* FunctionDeclaration */ + || kind === 183 /* FunctionExpression */ + || kind === 151 /* GetAccessor */ + || kind === 235 /* ImportClause */ + || kind === 233 /* ImportEqualsDeclaration */ + || kind === 238 /* ImportSpecifier */ + || kind === 226 /* InterfaceDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 148 /* MethodSignature */ + || kind === 229 /* ModuleDeclaration */ + || kind === 232 /* NamespaceExportDeclaration */ + || kind === 236 /* NamespaceImport */ + || kind === 144 /* Parameter */ + || kind === 256 /* PropertyAssignment */ + || kind === 147 /* PropertyDeclaration */ + || kind === 146 /* PropertySignature */ + || kind === 152 /* SetAccessor */ + || kind === 257 /* ShorthandPropertyAssignment */ + || kind === 227 /* TypeAliasDeclaration */ + || kind === 143 /* TypeParameter */ + || kind === 222 /* VariableDeclaration */ + || kind === 283 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 221 /* FunctionDeclaration */ - || kind === 240 /* MissingDeclaration */ - || kind === 222 /* ClassDeclaration */ - || kind === 223 /* InterfaceDeclaration */ - || kind === 224 /* TypeAliasDeclaration */ - || kind === 225 /* EnumDeclaration */ - || kind === 226 /* ModuleDeclaration */ - || kind === 231 /* ImportDeclaration */ - || kind === 230 /* ImportEqualsDeclaration */ - || kind === 237 /* ExportDeclaration */ - || kind === 236 /* ExportAssignment */ - || kind === 229 /* NamespaceExportDeclaration */; + return kind === 224 /* FunctionDeclaration */ + || kind === 243 /* MissingDeclaration */ + || kind === 225 /* ClassDeclaration */ + || kind === 226 /* InterfaceDeclaration */ + || kind === 227 /* TypeAliasDeclaration */ + || kind === 228 /* EnumDeclaration */ + || kind === 229 /* ModuleDeclaration */ + || kind === 234 /* ImportDeclaration */ + || kind === 233 /* ImportEqualsDeclaration */ + || kind === 240 /* ExportDeclaration */ + || kind === 239 /* ExportAssignment */ + || kind === 232 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 /* BreakStatement */ - || kind === 210 /* ContinueStatement */ - || kind === 218 /* DebuggerStatement */ - || kind === 205 /* DoStatement */ - || kind === 203 /* ExpressionStatement */ - || kind === 202 /* EmptyStatement */ - || kind === 208 /* ForInStatement */ - || kind === 209 /* ForOfStatement */ - || kind === 207 /* ForStatement */ - || kind === 204 /* IfStatement */ - || kind === 215 /* LabeledStatement */ - || kind === 212 /* ReturnStatement */ - || kind === 214 /* SwitchStatement */ - || kind === 216 /* ThrowStatement */ - || kind === 217 /* TryStatement */ - || kind === 201 /* VariableStatement */ - || kind === 206 /* WhileStatement */ - || kind === 213 /* WithStatement */ - || kind === 287 /* NotEmittedStatement */; + return kind === 214 /* BreakStatement */ + || kind === 213 /* ContinueStatement */ + || kind === 221 /* DebuggerStatement */ + || kind === 208 /* DoStatement */ + || kind === 206 /* ExpressionStatement */ + || kind === 205 /* EmptyStatement */ + || kind === 211 /* ForInStatement */ + || kind === 212 /* ForOfStatement */ + || kind === 210 /* ForStatement */ + || kind === 207 /* IfStatement */ + || kind === 218 /* LabeledStatement */ + || kind === 215 /* ReturnStatement */ + || kind === 217 /* SwitchStatement */ + || kind === 219 /* ThrowStatement */ + || kind === 220 /* TryStatement */ + || kind === 204 /* VariableStatement */ + || kind === 209 /* WhileStatement */ + || kind === 216 /* WithStatement */ + || kind === 291 /* NotEmittedStatement */ + || kind === 294 /* EndOfDeclarationMarker */ + || kind === 293 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -9901,93 +10246,93 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200 /* Block */; + || kind === 203 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 241 /* ExternalModuleReference */ - || kind === 140 /* QualifiedName */ + return kind === 244 /* ExternalModuleReference */ + || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 244 /* JsxOpeningElement */; + return node.kind === 247 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245 /* JsxClosingElement */; + return node.kind === 248 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 173 /* PropertyAccessExpression */; + || kind === 176 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 /* JsxElement */ - || kind === 248 /* JsxExpression */ - || kind === 243 /* JsxSelfClosingElement */ + return kind === 245 /* JsxElement */ + || kind === 251 /* JsxExpression */ + || kind === 246 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 /* JsxAttribute */ - || kind === 247 /* JsxSpreadAttribute */; + return kind === 249 /* JsxAttribute */ + || kind === 250 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247 /* JsxSpreadAttribute */; + return node.kind === 250 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246 /* JsxAttribute */; + return node.kind === 249 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 248 /* JsxExpression */; + || kind === 251 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 /* CaseClause */ - || kind === 250 /* DefaultClause */; + return kind === 252 /* CaseClause */ + || kind === 253 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251 /* HeritageClause */; + return node.kind === 254 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252 /* CatchClause */; + return node.kind === 255 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 253 /* PropertyAssignment */; + return node.kind === 256 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254 /* ShorthandPropertyAssignment */; + return node.kind === 257 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 259 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 256 /* SourceFile */; + return node.kind === 260 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -9999,6 +10344,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5 /* ESNext */: case 4 /* ES2017 */: return "lib.es2017.d.ts"; case 3 /* ES2016 */: @@ -10216,9 +10562,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 142 /* TypeParameter */) { + if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 226 /* InterfaceDeclaration */) { return current; } } @@ -10226,11 +10572,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 173 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10238,14 +10584,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 223 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 204 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10261,14 +10607,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 223 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 204 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10283,7 +10629,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 /* SourceFile */ + var ConstructorForKind = kind === 260 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10466,7 +10812,7 @@ var ts; ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(141 /* ComputedPropertyName */, location); + var node = createNode(142 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10479,17 +10825,8 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(name, initializer, location) { - return createParameterDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, name, - /*questionToken*/ undefined, - /*type*/ undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(143 /* Parameter */, location, flags); + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(144 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10499,17 +10836,17 @@ var ts; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + ts.createParameter = createParameter; + function updateParameter(node, decorators, modifiers, name, type, initializer) { if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); + return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; + ts.updateParameter = updateParameter; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(146 /* PropertyDeclaration */, location); + var node = createNode(147 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10527,7 +10864,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(148 /* MethodDeclaration */, location, flags); + var node = createNode(149 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10547,7 +10884,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(149 /* Constructor */, location, flags); + var node = createNode(150 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10565,7 +10902,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(150 /* GetAccessor */, location, flags); + var node = createNode(151 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10584,7 +10921,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(151 /* SetAccessor */, location, flags); + var node = createNode(152 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10603,7 +10940,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(168 /* ObjectBindingPattern */, location); + var node = createNode(171 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10616,7 +10953,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169 /* ArrayBindingPattern */, location); + var node = createNode(172 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10629,7 +10966,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170 /* BindingElement */, location); + var node = createNode(173 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10646,7 +10983,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171 /* ArrayLiteralExpression */, location); + var node = createNode(174 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10662,7 +10999,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172 /* ObjectLiteralExpression */, location); + var node = createNode(175 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10678,7 +11015,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173 /* PropertyAccessExpression */, location, flags); + var node = createNode(176 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10696,7 +11033,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174 /* ElementAccessExpression */, location); + var node = createNode(177 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10710,7 +11047,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* CallExpression */, location, flags); + var node = createNode(178 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10727,7 +11064,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176 /* NewExpression */, location, flags); + var node = createNode(179 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10742,7 +11079,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177 /* TaggedTemplateExpression */, location); + var node = createNode(180 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10756,7 +11093,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179 /* ParenthesizedExpression */, location); + var node = createNode(182 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10769,7 +11106,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(180 /* FunctionExpression */, location, flags); + var node = createNode(183 /* FunctionExpression */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10788,7 +11125,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(181 /* ArrowFunction */, location, flags); + var node = createNode(184 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10806,7 +11143,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182 /* DeleteExpression */, location); + var node = createNode(185 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10819,7 +11156,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183 /* TypeOfExpression */, location); + var node = createNode(186 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10832,7 +11169,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184 /* VoidExpression */, location); + var node = createNode(187 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10845,7 +11182,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185 /* AwaitExpression */, location); + var node = createNode(188 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10858,7 +11195,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186 /* PrefixUnaryExpression */, location); + var node = createNode(189 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10872,7 +11209,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187 /* PostfixUnaryExpression */, location); + var node = createNode(190 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10888,7 +11225,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(188 /* BinaryExpression */, location); + var node = createNode(191 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10903,7 +11240,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189 /* ConditionalExpression */, location); + var node = createNode(192 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10920,7 +11257,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190 /* TemplateExpression */, location); + var node = createNode(193 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10934,7 +11271,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191 /* YieldExpression */, location); + var node = createNode(194 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10948,7 +11285,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192 /* SpreadElementExpression */, location); + var node = createNode(195 /* SpreadElement */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10961,7 +11298,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193 /* ClassExpression */, location); + var node = createNode(196 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10979,12 +11316,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194 /* OmittedExpression */, location); + var node = createNode(197 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195 /* ExpressionWithTypeArguments */, location); + var node = createNode(198 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10999,7 +11336,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(198 /* TemplateSpan */, location); + var node = createNode(201 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11014,7 +11351,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(200 /* Block */, location, flags); + var block = createNode(203 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11030,7 +11367,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201 /* VariableStatement */, location, flags); + var node = createNode(204 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11045,7 +11382,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220 /* VariableDeclarationList */, location, flags); + var node = createNode(223 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11058,7 +11395,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219 /* VariableDeclaration */, location, flags); + var node = createNode(222 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11073,11 +11410,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202 /* EmptyStatement */, location); + return createNode(205 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203 /* ExpressionStatement */, location, flags); + var node = createNode(206 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11090,7 +11427,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204 /* IfStatement */, location); + var node = createNode(207 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11105,7 +11442,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205 /* DoStatement */, location); + var node = createNode(208 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11119,7 +11456,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206 /* WhileStatement */, location); + var node = createNode(209 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11133,7 +11470,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(210 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11149,7 +11486,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208 /* ForInStatement */, location); + var node = createNode(211 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11164,7 +11501,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209 /* ForOfStatement */, location); + var node = createNode(212 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11179,7 +11516,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210 /* ContinueStatement */, location); + var node = createNode(213 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11194,7 +11531,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211 /* BreakStatement */, location); + var node = createNode(214 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11209,7 +11546,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212 /* ReturnStatement */, location); + var node = createNode(215 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11222,7 +11559,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213 /* WithStatement */, location); + var node = createNode(216 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11236,7 +11573,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214 /* SwitchStatement */, location); + var node = createNode(217 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11250,7 +11587,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215 /* LabeledStatement */, location); + var node = createNode(218 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11264,7 +11601,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216 /* ThrowStatement */, location); + var node = createNode(219 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11277,7 +11614,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217 /* TryStatement */, location); + var node = createNode(220 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11292,7 +11629,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228 /* CaseBlock */, location); + var node = createNode(231 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11305,7 +11642,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(221 /* FunctionDeclaration */, location, flags); + var node = createNode(224 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11325,7 +11662,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222 /* ClassDeclaration */, location); + var node = createNode(225 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11343,7 +11680,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231 /* ImportDeclaration */, location); + var node = createNode(234 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11359,7 +11696,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232 /* ImportClause */, location); + var node = createNode(235 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11373,7 +11710,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233 /* NamespaceImport */, location); + var node = createNode(236 /* NamespaceImport */, location); node.name = name; return node; } @@ -11386,7 +11723,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234 /* NamedImports */, location); + var node = createNode(237 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11399,7 +11736,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235 /* ImportSpecifier */, location); + var node = createNode(238 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11413,7 +11750,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236 /* ExportAssignment */, location); + var node = createNode(239 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11429,7 +11766,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237 /* ExportDeclaration */, location); + var node = createNode(240 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11445,7 +11782,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238 /* NamedExports */, location); + var node = createNode(241 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11458,7 +11795,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239 /* ExportSpecifier */, location); + var node = createNode(242 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11473,7 +11810,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242 /* JsxElement */, location); + var node = createNode(245 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11488,7 +11825,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243 /* JsxSelfClosingElement */, location); + var node = createNode(246 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11502,7 +11839,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244 /* JsxOpeningElement */, location); + var node = createNode(247 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11516,7 +11853,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245 /* JsxClosingElement */, location); + var node = createNode(248 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11529,7 +11866,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246 /* JsxAttribute */, location); + var node = createNode(249 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11543,7 +11880,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247 /* JsxSpreadAttribute */, location); + var node = createNode(250 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11556,7 +11893,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248 /* JsxExpression */, location); + var node = createNode(251 /* JsxExpression */, location); node.expression = expression; return node; } @@ -11570,7 +11907,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(251 /* HeritageClause */, location); + var node = createNode(254 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11584,7 +11921,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249 /* CaseClause */, location); + var node = createNode(252 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11598,7 +11935,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250 /* DefaultClause */, location); + var node = createNode(253 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11611,7 +11948,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252 /* CatchClause */, location); + var node = createNode(255 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11626,7 +11963,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(253 /* PropertyAssignment */, location); + var node = createNode(256 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11641,12 +11978,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254 /* ShorthandPropertyAssignment */, location); + var node = createNode(257 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function createSpreadAssignment(expression, location) { + var node = createNode(258 /* SpreadAssignment */, location); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); @@ -11654,10 +11997,17 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSpreadAssignment(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpreadAssignment(expression, node), node); + } + return node; + } + ts.updateSpreadAssignment = updateSpreadAssignment; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(256 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(260 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11726,11 +12076,33 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(287 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(291 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + /** + * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in + * order to properly emit exports. + */ + function createEndOfDeclarationMarker(original) { + var node = createNode(294 /* EndOfDeclarationMarker */); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + /** + * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in + * order to properly emit exports. + */ + function createMergeDeclarationMarker(original) { + var node = createNode(293 /* MergeDeclarationMarker */); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; /** * Creates a synthetic expression to act as a placeholder for a not-emitted expression in * order to preserve comments or sourcemap positions. @@ -11740,7 +12112,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(292 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -11813,15 +12185,6 @@ var ts; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, - /*questionToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); - } - ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { return createCall(createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ @@ -11866,7 +12229,20 @@ var ts; react.parent = ts.getParseTreeNode(parent); return react; } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536 /* NoSourceMap */)); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -11886,10 +12262,22 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), + return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), /*typeArguments*/ undefined, argumentsList, location); } - ts.createReactCreateElement = createReactCreateElement; + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function createLetStatement(name, initializer, location) { + return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); + } + ts.createLetStatement = createLetStatement; function createLetDeclarationList(declarations, location) { return createVariableDeclarationList(declarations, location, 1 /* Let */); } @@ -11978,20 +12366,18 @@ var ts; // name => super[name] return createArrowFunction( /*modifiers*/ undefined, - /*typeParameters*/ undefined, [createParameter("name")], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createElementAccess(target, createIdentifier("name"))); + /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name")], + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createElementAccess(target, createIdentifier("name"))); } function createSeti(target) { // (name, value) => super[name] = value return createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, [ - createParameter("name"), - createParameter("value") + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "value") ], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } function createAdvancedAsyncSuperHelper() { // const _super = (function (geti, seti) { @@ -12016,7 +12402,7 @@ var ts; // set value(v) { seti(name, v); } var setter = createSetAccessor( /*decorators*/ undefined, - /*modifiers*/ undefined, "value", [createParameter("v")], createBlock([ + /*modifiers*/ undefined, "value", [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "v")], createBlock([ createStatement(createCall(createIdentifier("seti"), /*typeArguments*/ undefined, [ createIdentifier("name"), @@ -12026,9 +12412,8 @@ var ts; // return name => cache[name] || ... var getOrCreateAccessorsForName = createReturn(createArrowFunction( /*modifiers*/ undefined, - /*typeParameters*/ undefined, [createParameter("name")], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name")], + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ getter, setter ])))))); @@ -12044,8 +12429,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ - createParameter("geti"), - createParameter("seti") + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "geti"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "seti") ], /*type*/ undefined, createBlock([ createCache, @@ -12075,13 +12460,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12101,7 +12486,7 @@ var ts; } else { switch (callee.kind) { - case 173 /* PropertyAccessExpression */: { + case 176 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12115,7 +12500,7 @@ var ts; } break; } - case 174 /* ElementAccessExpression */: { + case 177 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12169,14 +12554,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12240,6 +12625,112 @@ var ts; /*location*/ method), /*original*/ method)); } + /** + * Gets the local name of a declaration. This is primarily used for declarations that can be + * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A + * local name will *never* be prefixed with an module or namespace export modifier like + * "exports." when emitted as an expression. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + } + ts.getLocalName = getLocalName; + /** + * Gets whether an identifier should only be referred to by its local name. + */ + function isLocalName(node) { + return (getEmitFlags(node) & 262144 /* LocalName */) !== 0; + } + ts.isLocalName = isLocalName; + /** + * Gets the export name of a declaration. This is primarily used for declarations that can be + * referred to by name in the declaration's immediate scope (classes, enums, namespaces). An + * export name will *always* be prefixed with an module or namespace export modifier like + * `"exports."` when emitted as an expression if the name points to an exported symbol. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 131072 /* ExportName */); + } + ts.getExportName = getExportName; + /** + * Gets whether an identifier should only be referred to by its export representation if the + * name points to an exported symbol. + */ + function isExportName(node) { + return (getEmitFlags(node) & 131072 /* ExportName */) !== 0; + } + ts.isExportName = isExportName; + /** + * Gets the name of a declaration for use in declarations. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name_11 = getMutableClone(node.name); + emitFlags |= getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 1536 /* NoSourceMap */; + if (!allowComments) + emitFlags |= 49152 /* NoComments */; + if (emitFlags) + setEmitFlags(name_11, emitFlags); + return name_11; + } + return getGeneratedNameForNode(node); + } + /** + * Gets the exported name of a declaration for use in expressions. + * + * An exported name will *always* be prefixed with an module or namespace export modifier like + * "exports." if the name points to an exported symbol. + * + * @param ns The namespace identifier. + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1 /* Export */)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + /** + * Gets a namespace-qualified name for use in expressions. + * + * @param ns The namespace identifier. + * @param name The name. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 1536 /* NoSourceMap */; + if (!allowComments) + emitFlags |= 49152 /* NoComments */; + if (emitFlags) + setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; // Utilities function isUseStrictPrologue(node) { return node.expression.text === "use strict"; @@ -12329,7 +12820,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 179 /* ParenthesizedExpression */) { + if (skipped.kind === 182 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12363,8 +12854,8 @@ 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(188 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(191 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(191 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12373,7 +12864,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 191 /* YieldExpression */) { + && operand.kind === 194 /* YieldExpression */) { return false; } return true; @@ -12461,7 +12952,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12484,9 +12975,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return createParen(expression); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12511,7 +13002,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 179 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12549,7 +13040,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(191 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12560,7 +13051,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { + if (kind === 183 /* FunctionExpression */ || kind === 184 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12568,7 +13059,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { + if (leftmostExpressionKind === 175 /* ObjectLiteralExpression */ || leftmostExpressionKind === 183 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12592,21 +13083,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: node = node.operand; continue; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: node = node.left; continue; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: node = node.condition; continue; - case 175 /* CallExpression */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 178 /* CallExpression */: + case 177 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: node = node.expression; continue; - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -12615,19 +13106,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 175 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; - })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); - var OuterExpressionKinds = ts.OuterExpressionKinds; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } var previousNode; @@ -12647,7 +13138,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */) { + while (node.kind === 182 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12661,7 +13152,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288 /* PartiallyEmittedExpression */) { + while (node.kind === 292 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -12736,7 +13227,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 === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12878,13 +13369,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_12 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 234 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 240 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12941,6 +13432,363 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + context.startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); + addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 184 /* 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 + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = createReturn(expression, /*location*/ body); + setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + setEmitFlags(block, 32 /* SingleLine */); + } + if (closeBraceLocation) { + setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + } + setOriginalNode(block, node.body); + return block; + } + ts.transformFunctionBody = transformFunctionBody; + /** + * Adds a statement to capture the `this` of a function declaration if it is needed. + * + * @param statements The statements for the new function body. + * @param node A node. + */ + function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { + if (node.transformFlags & 524288 /* ContainsCapturedLexicalThis */ && node.kind !== 184 /* ArrowFunction */) { + captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + } + } + ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; + function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + ts.captureThisForNode = captureThisForNode; + /** + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. + * + * @param node A function-like node. + */ + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 2097152 /* ContainsDefaultValueAssignments */) !== 0; + } + /** + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + */ + function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_13 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_13)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_13, initializer, visitor, convertObjectRest); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_13, initializer, visitor); + } + } + } + ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; + /** + * Adds statements to the body of a function-like node for parameters with binding patterns + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { + var temp = getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(setEmitFlags(createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608 /* CustomPrologue */)); + } + else if (initializer) { + statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + } + } + /** + * Adds statements to the body of a function-like node for parameters with initializers. + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ + createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536 /* NoSourceMap */), setEmitFlags(initializer, 1536 /* NoSourceMap */ | getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); + } + /** + * Gets a value indicating whether we need to add statements to handle a rest parameter. + * + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + } + /** + * Adds statements to the body of a function-like node if it contains a rest parameter. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = getMutableClone(parameter.name); + setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = createLoopVariable(); + // var param = []; + statements.push(setEmitFlags(createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration(declarationName, + /*type*/ undefined, createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = createFor(createVariableDeclarationList([ + createVariableDeclaration(temp, /*type*/ undefined, createLiteral(restIndex)) + ], /*location*/ parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), + /*location*/ parameter), createPostfixIncrement(temp, /*location*/ parameter), createBlock([ + startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + startOnNewLine(forStatement); + statements.push(forStatement); + } + ts.addRestParameterIfNeeded = addRestParameterIfNeeded; + function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = convertObjectRest ? undefined : createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? createUniqueName(expression.text) + : createTempVariable(/*recordTempVariable*/ undefined); + var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, + /*recordTempVariable*/ undefined, convertObjectRest); + var declarationList = createVariableDeclarationList(declarations, /*location*/ initializer); + setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(createVariableStatement( + /*modifiers*/ undefined, setOriginalNode(createVariableDeclarationList([ + createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), + /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, context.hoistVariableDeclaration, visitor, convertObjectRest))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the expression + setEmitFlags(expression, 1536 /* NoSourceMap */ | getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = createBlock(createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement; + if (convertObjectRest) { + forStatement = createForOf(createVariableDeclarationList([ + createVariableDeclaration(rhsReference, /*type*/ undefined, /*initializer*/ undefined, /*location*/ node.expression) + ], /*location*/ node.expression), node.expression, body, + /*location*/ node); + } + else { + forStatement = createFor(setEmitFlags(createVariableDeclarationList([ + createVariableDeclaration(counter, /*type*/ undefined, createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), 16777216 /* NoHoisting */), createLessThan(counter, createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + } + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; + } + ts.convertForOf = convertForOf; })(ts || (ts = {})); /// /// @@ -12952,13 +13800,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256 /* SourceFile */) { + if (kind === 260 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 140 /* FirstNode */) { + else if (kind < 141 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13001,26 +13849,28 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: + case 258 /* SpreadAssignment */: + return visitNode(cbNode, node.expression); + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13029,24 +13879,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13057,309 +13907,313 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 162 /* TupleType */: + case 163 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: + case 168 /* TypeOperator */: return visitNode(cbNode, node.type); - case 167 /* LiteralType */: + case 169 /* IndexedAccessType */: + return visitNode(cbNode, node.objectType) || + visitNode(cbNode, node.indexType); + case 170 /* LiteralType */: return visitNode(cbNode, node.literal); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196 /* AsExpression */: + case 199 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: return visitNode(cbNode, node.label); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 249 /* CaseClause */: + case 252 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144 /* Decorator */: + case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241 /* ExternalModuleReference */: + case 244 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 257 /* JSDocTypeExpression */: + case 261 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 261 /* JSDocUnionType */: + case 265 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 262 /* JSDocTupleType */: + case 266 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 260 /* JSDocArrayType */: + case 264 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 264 /* JSDocNonNullableType */: + case 268 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 263 /* JSDocNullableType */: + case 267 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 265 /* JSDocRecordType */: + case 269 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 267 /* JSDocTypeReference */: + case 271 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 268 /* JSDocOptionalType */: + case 272 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 269 /* JSDocFunctionType */: + case 273 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 270 /* JSDocVariadicType */: + case 274 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 271 /* JSDocConstructorType */: + case 275 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 272 /* JSDocThisType */: + case 276 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 266 /* JSDocRecordMember */: + case 270 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273 /* JSDocComment */: + case 277 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 275 /* JSDocParameterTag */: + case 279 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276 /* JSDocReturnTag */: + case 280 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 277 /* JSDocTypeTag */: + case 281 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 278 /* JSDocTemplateTag */: + case 282 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281 /* JSDocTypeLiteral */: + case 285 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280 /* JSDocPropertyTag */: + case 284 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 282 /* JSDocLiteralType */: + case 286 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -13373,6 +14227,10 @@ var ts; return result; } ts.createSourceFile = createSourceFile; + function parseIsolatedEntityName(text, languageVersion) { + return Parser.parseIsolatedEntityName(text, languageVersion); + } + ts.parseIsolatedEntityName = parseIsolatedEntityName; function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -13414,8 +14272,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; + var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 65536 /* DisallowInContext */ | 262144 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var TokenConstructor; @@ -13513,6 +14371,16 @@ var ts; return result; } Parser.parseSourceFile = parseSourceFile; + function parseIsolatedEntityName(content, languageVersion) { + initializeState(content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + // Prime the scanner. + nextToken(); + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + clearState(); + return isInvalid ? entityName : undefined; + } + Parser.parseIsolatedEntityName = parseIsolatedEntityName; function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; @@ -13529,7 +14397,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 1048576 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 2097152 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -13617,7 +14485,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(256 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(260 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13637,16 +14505,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 32768 /* DisallowInContext */); + setContextFlag(val, 65536 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 65536 /* YieldContext */); + setContextFlag(val, 131072 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 131072 /* DecoratorContext */); + setContextFlag(val, 262144 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 262144 /* AwaitContext */); + setContextFlag(val, 524288 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -13687,40 +14555,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(32768 /* DisallowInContext */, func); + return doOutsideOfContext(65536 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(32768 /* DisallowInContext */, func); + return doInsideOfContext(65536 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(65536 /* YieldContext */, func); + return doInsideOfContext(131072 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(131072 /* DecoratorContext */, func); + return doInsideOfContext(262144 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(262144 /* AwaitContext */, func); + return doInsideOfContext(524288 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144 /* AwaitContext */, func); + return doOutsideOfContext(524288 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 /* YieldContext */ | 262144 /* AwaitContext */, func); + return doInsideOfContext(131072 /* YieldContext */ | 524288 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(65536 /* YieldContext */); + return inContext(131072 /* YieldContext */); } function inDisallowInContext() { - return inContext(32768 /* DisallowInContext */); + return inContext(65536 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(131072 /* DecoratorContext */); + return inContext(262144 /* DecoratorContext */); } function inAwaitContext() { - return inContext(262144 /* AwaitContext */); + return inContext(524288 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -13901,7 +14769,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -13924,7 +14792,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288 /* ThisNodeHasError */; + node.flags |= 1048576 /* ThisNodeHasError */; } return node; } @@ -13993,7 +14861,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(141 /* ComputedPropertyName */); + var node = createNode(142 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -14080,9 +14948,11 @@ var ts; // which would be a candidate for improved error reporting. return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + case 17 /* RestProperties */: + return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. @@ -14102,29 +14972,29 @@ var ts; return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); - case 18 /* TypeArguments */: - case 19 /* TupleElementTypes */: + case 19 /* TypeArguments */: + case 20 /* TupleElementTypes */: return token() === 25 /* CommaToken */ || isStartOfType(); - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: return isHeritageClause(); - case 21 /* ImportOrExportSpecifiers */: + case 22 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; - case 22 /* JSDocFunctionParameters */: - case 23 /* JSDocTypeArguments */: - case 25 /* JSDocTupleTypes */: + case 23 /* JSDocFunctionParameters */: + case 24 /* JSDocTypeArguments */: + case 26 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 24 /* JSDocRecordMembers */: + case 25 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -14177,7 +15047,7 @@ var ts; case 6 /* EnumMembers */: case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: - case 21 /* ImportOrExportSpecifiers */: + case 22 /* ImportOrExportSpecifiers */: return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; @@ -14185,35 +15055,36 @@ var ts; return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: - case 19 /* TupleElementTypes */: + case 20 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: + case 17 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 18 /* TypeArguments */: + case 19 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token return token() !== 25 /* CommaToken */; - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); - case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocFunctionParameters */: return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; - case 23 /* JSDocTypeArguments */: + case 24 /* JSDocTypeArguments */: return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; - case 25 /* JSDocTupleTypes */: + case 26 /* JSDocTupleTypes */: return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; - case 24 /* JSDocRecordMembers */: + case 25 /* JSDocRecordMembers */: return token() === 17 /* CloseBraceToken */; } } @@ -14240,7 +15111,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 26 /* Count */; kind++) { + for (var kind = 0; kind < 27 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -14315,7 +15186,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 1540096 /* ContextFlags */; + var nodeContextFlags = node.flags & 3080192 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -14350,20 +15221,22 @@ var ts; return isReusableVariableDeclaration(node); case 16 /* Parameters */: return isReusableParameter(node); + case 17 /* RestProperties */: + return false; // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 19 /* TupleElementTypes */: + case 20 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -14371,7 +15244,7 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 18 /* TypeArguments */: + case 19 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. @@ -14395,14 +15268,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 149 /* Constructor */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 146 /* PropertyDeclaration */: - case 199 /* SemicolonClassElement */: + case 150 /* Constructor */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 202 /* SemicolonClassElement */: return true; - case 148 /* MethodDeclaration */: + case 149 /* 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. @@ -14417,8 +15290,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: return true; } } @@ -14427,58 +15300,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 201 /* VariableStatement */: - case 200 /* Block */: - case 204 /* IfStatement */: - case 203 /* ExpressionStatement */: - case 216 /* ThrowStatement */: - case 212 /* ReturnStatement */: - case 214 /* SwitchStatement */: - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 207 /* ForStatement */: - case 206 /* WhileStatement */: - case 213 /* WithStatement */: - case 202 /* EmptyStatement */: - case 217 /* TryStatement */: - case 215 /* LabeledStatement */: - case 205 /* DoStatement */: - case 218 /* DebuggerStatement */: - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: - case 236 /* ExportAssignment */: - case 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 224 /* FunctionDeclaration */: + case 204 /* VariableStatement */: + case 203 /* Block */: + case 207 /* IfStatement */: + case 206 /* ExpressionStatement */: + case 219 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 217 /* SwitchStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 210 /* ForStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: + case 205 /* EmptyStatement */: + case 220 /* TryStatement */: + case 218 /* LabeledStatement */: + case 208 /* DoStatement */: + case 221 /* DebuggerStatement */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 227 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 259 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 153 /* ConstructSignature */: - case 147 /* MethodSignature */: - case 154 /* IndexSignature */: - case 145 /* PropertySignature */: - case 152 /* CallSignature */: + case 154 /* ConstructSignature */: + case 148 /* MethodSignature */: + case 155 /* IndexSignature */: + case 146 /* PropertySignature */: + case 153 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 219 /* VariableDeclaration */) { + if (node.kind !== 222 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14499,7 +15372,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 143 /* Parameter */) { + if (node.kind !== 144 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14521,6 +15394,7 @@ var ts; 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 17 /* 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; @@ -14532,17 +15406,17 @@ var ts; case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 17 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 19 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 20 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 21 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 18 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 19 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 20 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 21 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; - case 22 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 23 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 25 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 24 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 23 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 24 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 26 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 25 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -14611,7 +15485,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(140 /* QualifiedName */, entity.pos); // !!! + var node = createNode(141 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14650,7 +15524,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190 /* TemplateExpression */); + var template = createNode(193 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14662,7 +15536,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198 /* TemplateSpan */); + var span = createNode(201 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -14717,33 +15591,33 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(156 /* TypeReference */, typeName.pos); + var node = createNode(157 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(155 /* TypePredicate */, lhs.pos); + var node = createNode(156 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(166 /* ThisType */); + var node = createNode(167 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(159 /* TypeQuery */); + var node = createNode(160 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(142 /* TypeParameter */); + var node = createNode(143 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -14768,7 +15642,7 @@ var ts; } function parseTypeParameters() { if (token() === 26 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { @@ -14781,7 +15655,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(143 /* Parameter */); + var node = createNode(144 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -14880,7 +15754,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153 /* ConstructSignature */) { + if (kind === 154 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -14944,7 +15818,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(154 /* IndexSignature */, fullStart); + var node = createNode(155 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -14956,7 +15830,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(147 /* MethodSignature */, fullStart); + var method = createNode(148 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14967,7 +15841,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(145 /* PropertySignature */, fullStart); + var property = createNode(146 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -15016,10 +15890,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(152 /* CallSignature */); + return parseSignatureMember(153 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(153 /* ConstructSignature */); + return parseSignatureMember(154 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -15033,7 +15907,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(160 /* TypeLiteral */); + var node = createNode(161 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15049,12 +15923,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(162 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + var node = createNode(163 /* TupleType */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(165 /* ParenthesizedType */); + var node = createNode(166 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -15062,7 +15936,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158 /* ConstructorType */) { + if (kind === 159 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15073,7 +15947,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167 /* LiteralType */); + var node = createNode(170 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15084,12 +15958,12 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 135 /* SymbolKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -15127,16 +16001,16 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: - case 128 /* NeverKeyword */: + case 129 /* NeverKeyword */: case 16 /* OpenBraceToken */: case 20 /* OpenBracketToken */: case 26 /* LessThanToken */: @@ -15163,13 +16037,36 @@ var ts; function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { - parseExpected(21 /* CloseBracketToken */); - var node = createNode(161 /* ArrayType */, type.pos); - node.elementType = type; - type = finishNode(node); + if (isStartOfType()) { + var node = createNode(169 /* IndexedAccessType */, type.pos); + node.objectType = type; + node.indexType = parseType(); + parseExpected(21 /* CloseBracketToken */); + type = finishNode(node); + } + else { + var node = createNode(162 /* ArrayType */, type.pos); + node.elementType = type; + parseExpected(21 /* CloseBracketToken */); + type = finishNode(node); + } } return type; } + function parseTypeOperator(operator) { + var node = createNode(168 /* TypeOperator */); + parseExpected(operator); + node.operator = operator; + node.type = parseTypeOperatorOrHigher(); + return finishNode(node); + } + function parseTypeOperatorOrHigher() { + switch (token()) { + case 126 /* KeyOfKeyword */: + return parseTypeOperator(126 /* KeyOfKeyword */); + } + return parseArrayTypeOrHigher(); + } function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { var type = parseConstituentType(); if (token() === operator) { @@ -15185,10 +16082,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -15245,7 +16142,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15264,14 +16161,14 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(327680 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(655360 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(157 /* FunctionType */); + return parseFunctionOrConstructorType(158 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(158 /* ConstructorType */); + return parseFunctionOrConstructorType(159 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -15472,7 +16369,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191 /* YieldExpression */); + var node = createNode(194 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -15494,13 +16391,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(181 /* ArrowFunction */, asyncModifier.pos); + node = createNode(184 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181 /* ArrowFunction */, identifier.pos); + node = createNode(184 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(143 /* Parameter */, identifier.pos); + var parameter = createNode(144 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15682,7 +16579,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181 /* ArrowFunction */); + var node = createNode(184 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15748,7 +16645,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(192 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15761,7 +16658,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15869,39 +16766,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188 /* BinaryExpression */, left.pos); + var node = createNode(191 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(196 /* AsExpression */, left.pos); + var node = createNode(199 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(189 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182 /* DeleteExpression */); + var node = createNode(185 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183 /* TypeOfExpression */); + var node = createNode(186 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184 /* VoidExpression */); + var node = createNode(187 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15917,7 +16814,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185 /* AwaitExpression */); + var node = createNode(188 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15960,7 +16857,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 181 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, 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 { @@ -16056,7 +16953,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(189 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -16069,7 +16966,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(190 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16173,7 +17070,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(173 /* PropertyAccessExpression */, expression.pos); + var node = createNode(176 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -16198,8 +17095,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 244 /* JsxOpeningElement */) { - var node = createNode(242 /* JsxElement */, opening.pos); + if (opening.kind === 247 /* JsxOpeningElement */) { + var node = createNode(245 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16209,7 +17106,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 246 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16224,7 +17121,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(188 /* BinaryExpression */, result.pos); + var badNode = createNode(191 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16283,7 +17180,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(244 /* JsxOpeningElement */, fullStart); + node = createNode(247 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -16295,7 +17192,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(243 /* JsxSelfClosingElement */, fullStart); + node = createNode(246 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16311,7 +17208,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(176 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16319,7 +17216,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248 /* JsxExpression */); + var node = createNode(251 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -16338,7 +17235,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246 /* JsxAttribute */); + var node = createNode(249 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -16353,7 +17250,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247 /* JsxSpreadAttribute */); + var node = createNode(250 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -16361,7 +17258,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245 /* JsxClosingElement */); + var node = createNode(248 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16374,7 +17271,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178 /* TypeAssertionExpression */); + var node = createNode(181 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -16385,7 +17282,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(176 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16393,14 +17290,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(200 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(174 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(177 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -16416,7 +17313,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(180 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -16439,7 +17336,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(178 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16447,7 +17344,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(178 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16466,7 +17363,7 @@ var ts; if (!parseOptional(26 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(19 /* TypeArguments */, parseType); if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -16557,28 +17454,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179 /* ParenthesizedExpression */); + var node = createNode(182 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192 /* SpreadElementExpression */); + var node = createNode(195 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(197 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171 /* ArrayLiteralExpression */); + var node = createNode(174 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16589,15 +17486,21 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(132 /* SetKeyword */)) { - return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(133 /* SetKeyword */)) { + return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + if (dotDotDotToken) { + var spreadElement = createNode(258 /* SpreadAssignment */, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -16619,7 +17522,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(257 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -16630,7 +17533,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(256 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16640,7 +17543,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172 /* ObjectLiteralExpression */); + var node = createNode(175 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16659,7 +17562,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(180 /* FunctionExpression */); + var node = createNode(183 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -16681,7 +17584,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176 /* NewExpression */); + var node = createNode(179 /* NewExpression */); parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -16692,7 +17595,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200 /* Block */); + var node = createNode(203 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16725,12 +17628,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202 /* EmptyStatement */); + var node = createNode(205 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(204 /* IfStatement */); + var node = createNode(207 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16740,7 +17643,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205 /* DoStatement */); + var node = createNode(208 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -16755,7 +17658,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206 /* WhileStatement */); + var node = createNode(209 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16778,21 +17681,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(208 /* ForInStatement */, pos); + var forInStatement = createNode(211 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(139 /* OfKeyword */)) { - var forOfStatement = createNode(209 /* ForOfStatement */, pos); + else if (parseOptional(140 /* OfKeyword */)) { + var forOfStatement = createNode(212 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207 /* ForStatement */, pos); + var forStatement = createNode(210 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -16810,7 +17713,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 214 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16818,7 +17721,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212 /* ReturnStatement */); + var node = createNode(215 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16827,7 +17730,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213 /* WithStatement */); + var node = createNode(216 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16836,7 +17739,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249 /* CaseClause */); + var node = createNode(252 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -16844,7 +17747,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250 /* DefaultClause */); + var node = createNode(253 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -16854,12 +17757,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214 /* SwitchStatement */); + var node = createNode(217 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(231 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -16874,7 +17777,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(216 /* ThrowStatement */); + var node = createNode(219 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -16882,7 +17785,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(217 /* TryStatement */); + var node = createNode(220 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -16895,7 +17798,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252 /* CatchClause */); + var result = createNode(255 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16905,7 +17808,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218 /* DebuggerStatement */); + var node = createNode(221 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -16917,13 +17820,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(218 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(206 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16973,10 +17876,10 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 116 /* AbstractKeyword */: case 119 /* AsyncKeyword */: @@ -16984,14 +17887,14 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 113 /* PublicKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 138 /* GlobalKeyword */: + case 139 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -17051,17 +17954,17 @@ var ts; case 119 /* AsyncKeyword */: case 123 /* DeclareKeyword */: case 108 /* InterfaceKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: - case 135 /* TypeKeyword */: - case 138 /* GlobalKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: + case 136 /* TypeKeyword */: + case 139 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* 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); @@ -17104,9 +18007,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(210 /* ContinueStatement */); + return parseBreakOrContinueStatement(213 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(211 /* BreakStatement */); + return parseBreakOrContinueStatement(214 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -17126,9 +18029,9 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 135 /* TypeKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 136 /* TypeKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: case 82 /* EnumKeyword */: @@ -17139,8 +18042,8 @@ var ts; case 113 /* PublicKeyword */: case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: - case 138 /* GlobalKeyword */: + case 130 /* ReadonlyKeyword */: + case 139 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17163,13 +18066,13 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 138 /* GlobalKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 139 /* GlobalKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -17188,7 +18091,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 node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(243 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17210,16 +18113,17 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(194 /* OmittedExpression */); + return createNode(197 /* OmittedExpression */); } - var node = createNode(170 /* BindingElement */); + var node = createNode(173 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170 /* BindingElement */); + var node = createNode(173 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { @@ -17234,14 +18138,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168 /* ObjectBindingPattern */); + var node = createNode(171 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169 /* ArrayBindingPattern */); + var node = createNode(172 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -17260,7 +18164,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219 /* VariableDeclaration */); + var node = createNode(222 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17269,7 +18173,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220 /* VariableDeclarationList */); + var node = createNode(223 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -17292,7 +18196,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17307,7 +18211,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201 /* VariableStatement */, fullStart); + var node = createNode(204 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17315,7 +18219,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* FunctionDeclaration */, fullStart); + var node = createNode(224 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -17328,7 +18232,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(149 /* Constructor */, pos); + var node = createNode(150 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -17337,7 +18241,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(148 /* MethodDeclaration */, fullStart); + var method = createNode(149 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17350,7 +18254,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(146 /* PropertyDeclaration */, fullStart); + var property = createNode(147 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17367,7 +18271,7 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = ts.hasModifier(property, 32 /* Static */) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(65536 /* YieldContext */ | 32768 /* DisallowInContext */, parseNonParameterInitializer); + : doOutsideOfContext(131072 /* YieldContext */ | 65536 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -17402,7 +18306,7 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: return true; default: return false; @@ -17443,7 +18347,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 === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -17473,7 +18377,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(144 /* Decorator */, decoratorStart); + var decorator = createNode(145 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17539,7 +18443,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(199 /* SemicolonClassElement */); + var result = createNode(202 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17567,8 +18471,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); + var name_14 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -17577,10 +18481,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 193 /* ClassExpression */); + /*modifiers*/ undefined, 196 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 225 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17618,13 +18522,13 @@ var ts; // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(20 /* HeritageClauses */, parseHeritageClause); + return parseList(21 /* HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(251 /* HeritageClause */); + var node = createNode(254 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -17633,10 +18537,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195 /* ExpressionWithTypeArguments */); + var node = createNode(198 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } @@ -17647,7 +18551,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* InterfaceDeclaration */, fullStart); + var node = createNode(226 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -17658,10 +18562,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* TypeAliasDeclaration */, fullStart); + var node = createNode(227 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135 /* TypeKeyword */); + parseExpected(136 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -17674,13 +18578,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(255 /* EnumMember */, scanner.getStartPos()); + var node = createNode(259 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* EnumDeclaration */, fullStart); + var node = createNode(228 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -17695,7 +18599,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(230 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -17706,7 +18610,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(229 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -17720,10 +18624,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(229 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138 /* GlobalKeyword */) { + if (token() === 139 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17741,15 +18645,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 138 /* GlobalKeyword */) { + if (token() === 139 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(127 /* NamespaceKeyword */)) { + else if (parseOptional(128 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(126 /* ModuleKeyword */); + parseExpected(127 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17757,7 +18661,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 /* RequireKeyword */ && + return token() === 131 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -17767,11 +18671,11 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(232 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); - parseExpected(127 /* NamespaceKeyword */); + parseExpected(128 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); @@ -17782,11 +18686,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(233 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17797,7 +18701,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(234 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -17807,7 +18711,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17820,7 +18724,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(232 /* ImportClause */, fullStart); + var importClause = createNode(235 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17830,7 +18734,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(237 /* NamedImports */); } return finishNode(importClause); } @@ -17840,8 +18744,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(241 /* ExternalModuleReference */); - parseExpected(130 /* RequireKeyword */); + var node = createNode(244 /* ExternalModuleReference */); + parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(19 /* CloseParenToken */); @@ -17863,7 +18767,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(233 /* NamespaceImport */); + var namespaceImport = createNode(236 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -17878,14 +18782,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 237 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239 /* ExportSpecifier */); + return parseImportOrExportSpecifier(242 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235 /* ImportSpecifier */); + return parseImportOrExportSpecifier(238 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17910,27 +18814,27 @@ var ts; else { node.name = identifierName; } - if (kind === 235 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 238 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(237 /* ExportDeclaration */, fullStart); + var node = createNode(240 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(238 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(241 /* 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() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(137 /* FromKeyword */); + if (token() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(138 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17938,7 +18842,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236 /* ExportAssignment */, fullStart); + var node = createNode(239 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -18020,10 +18924,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ - || node.kind === 231 /* ImportDeclaration */ - || node.kind === 236 /* ExportAssignment */ - || node.kind === 237 /* ExportDeclaration */ + || node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 244 /* ExternalModuleReference */ + || node.kind === 234 /* ImportDeclaration */ + || node.kind === 239 /* ExportAssignment */ + || node.kind === 240 /* ExportDeclaration */ ? node : undefined; }); @@ -18047,16 +18951,17 @@ var ts; ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 26] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -18084,8 +18989,8 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); + initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 5 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -18097,7 +19002,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(261 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -18108,12 +19013,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(261 /* JSDocUnionType */, type.pos); + var unionType = createNode(265 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(272 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -18124,20 +19029,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(260 /* JSDocArrayType */, type.pos); + var arrayType = createNode(264 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(263 /* JSDocNullableType */, type.pos); + var nullableType = createNode(267 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(268 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -18171,14 +19076,14 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -18189,30 +19094,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272 /* JSDocThisType */); + var result = createNode(276 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271 /* JSDocConstructorType */); + var result = createNode(275 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270 /* JSDocVariadicType */); + var result = createNode(274 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269 /* JSDocFunctionType */); + var result = createNode(273 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); - result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19 /* CloseParenToken */); if (token() === 55 /* ColonToken */) { @@ -18222,7 +19127,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(143 /* Parameter */); + var parameter = createNode(144 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -18231,7 +19136,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267 /* JSDocTypeReference */); + var result = createNode(271 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -18252,7 +19157,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(24 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28 /* GreaterThanToken */); @@ -18266,26 +19171,26 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(140 /* QualifiedName */, left.pos); + var result = createNode(141 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(265 /* JSDocRecordType */); + var result = createNode(269 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264 /* JSDocNonNullableType */); + var result = createNode(268 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262 /* JSDocTupleType */); + var result = createNode(266 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21 /* CloseBracketToken */); return finishNode(result); @@ -18297,7 +19202,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261 /* JSDocUnionType */); + var result = createNode(265 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -18313,12 +19218,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258 /* JSDocAllType */); + var result = createNode(262 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282 /* JSDocLiteralType */); + var result = createNode(286 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -18341,17 +19246,17 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(259 /* JSDocUnknownType */, pos); + var result = createNode(263 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(263 /* JSDocNullableType */, pos); + var result = createNode(267 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18504,7 +19409,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(273 /* JSDocComment */, start); + var result = createNode(277 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18617,7 +19522,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274 /* JSDocTag */, atToken.pos); + var result = createNode(278 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18674,7 +19579,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275 /* JSDocParameterTag */, atToken.pos); + var result = createNode(279 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18685,20 +19590,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 276 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 280 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276 /* JSDocReturnTag */, atToken.pos); + var result = createNode(280 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 277 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 281 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277 /* JSDocTypeTag */, atToken.pos); + var result = createNode(281 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18713,7 +19618,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(284 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18723,7 +19628,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(283 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -18737,11 +19642,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 271 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_11 = jsDocTypeReference.name; - if (name_11.text === "Object") { + var name_15 = jsDocTypeReference.name; + if (name_15.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18755,7 +19660,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(285 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18796,7 +19701,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(226 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(229 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -18842,20 +19747,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 278 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_12 = parseJSDocIdentifierName(); + var name_16 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_12) { + if (!name_16) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); - typeParameter.name = name_12; + var typeParameter = createNode(143 /* TypeParameter */, name_16.pos); + typeParameter.name = name_16; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -18866,7 +19771,7 @@ var ts; break; } } - var result = createNode(278 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(282 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -19377,25 +20282,25 @@ var ts; /* @internal */ var ts; (function (ts) { + var ModuleInstanceState; (function (ModuleInstanceState) { ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 226 /* InterfaceDeclaration */ || node.kind === 227 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 234 /* ImportDeclaration */ || node.kind === 233 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 227 /* ModuleBlock */) { + else if (node.kind === 230 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19414,7 +20319,7 @@ var ts; }); return state_1; } - else if (node.kind === 226 /* ModuleDeclaration */) { + else if (node.kind === 229 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19555,7 +20460,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 229 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19568,7 +20473,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19580,21 +20485,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 149 /* Constructor */: + case 150 /* Constructor */: return "__constructor"; - case 157 /* FunctionType */: - case 152 /* CallSignature */: + case 158 /* FunctionType */: + case 153 /* CallSignature */: return "__call"; - case 158 /* ConstructorType */: - case 153 /* ConstructSignature */: + case 159 /* ConstructorType */: + case 154 /* ConstructSignature */: return "__new"; - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return "__index"; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return "__export"; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19609,22 +20514,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: + case 224 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 269 /* JSDocFunctionType */: + case 273 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143 /* Parameter */: + case 144 /* 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 === 269 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 273 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 204 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -19711,7 +20616,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 && - (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 239 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19731,7 +20636,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 242 /* ExportSpecifier */ || (node.kind === 233 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19754,7 +20659,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 279 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 283 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -19816,8 +20721,8 @@ var ts; var saveReturnTarget = currentReturnTarget; var saveActiveLabels = activeLabels; var saveHasExplicitReturn = hasExplicitReturn; - var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !!ts.getImmediatelyInvokedFunctionExpression(node); - // An IIFE is considered part of the containing control flow. Return statements behave + var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !ts.hasModifier(node, 256 /* Async */) && !!ts.getImmediatelyInvokedFunctionExpression(node); + // A non-async IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (isIIFE) { currentReturnTarget = createBranchLabel(); @@ -19836,13 +20741,13 @@ var ts; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) // Reset all emit helper flags on node (for incremental scenarios) - node.flags &= ~32128 /* ReachabilityAndEmitFlags */; + node.flags &= ~64896 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { node.flags |= 128 /* HasImplicitReturn */; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -19898,64 +20803,64 @@ var ts; return; } switch (node.kind) { - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: bindWhileStatement(node); break; - case 205 /* DoStatement */: + case 208 /* DoStatement */: bindDoStatement(node); break; - case 207 /* ForStatement */: + case 210 /* ForStatement */: bindForStatement(node); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 204 /* IfStatement */: + case 207 /* IfStatement */: bindIfStatement(node); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 219 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 217 /* TryStatement */: + case 220 /* TryStatement */: bindTryStatement(node); break; - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: bindSwitchStatement(node); break; - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: bindCaseBlock(node); break; - case 249 /* CaseClause */: + case 252 /* CaseClause */: bindCaseClause(node); break; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: bindLabeledStatement(node); break; - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 175 /* CallExpression */: + case 178 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19967,15 +20872,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return hasNarrowableArgument(expr); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -19983,7 +20888,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 176 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19994,14 +20899,14 @@ var ts; } } } - if (expr.expression.kind === 173 /* PropertyAccessExpression */ && + if (expr.expression.kind === 176 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 186 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -20022,9 +20927,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -20119,33 +21024,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204 /* IfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 207 /* IfStatement */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: return parent.expression === node; - case 207 /* ForStatement */: - case 189 /* ConditionalExpression */: + case 210 /* ForStatement */: + case 192 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 182 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 189 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 191 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 /* ParenthesizedExpression */ || - node.parent.kind === 186 /* PrefixUnaryExpression */ && + while (node.parent.kind === 182 /* ParenthesizedExpression */ || + node.parent.kind === 189 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -20187,8 +21092,13 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 218 /* LabeledStatement */ + ? ts.lastOrUndefined(activeLabels) + : undefined; + // if do statement is wrapped in labeled statement then target labels for break/continue with or without + // label should be the same + var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); + var postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel(); addAntecedent(preDoLabel, currentFlow); currentFlow = preDoLabel; bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); @@ -20219,7 +21129,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220 /* VariableDeclarationList */) { + if (node.initializer.kind !== 223 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20241,7 +21151,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212 /* ReturnStatement */) { + if (node.kind === 215 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20261,7 +21171,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 214 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20327,7 +21237,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 250 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 253 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -20390,11 +21300,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); + if (!node.statement || node.statement.kind !== 208 /* DoStatement */) { + // do statement sets current flow inside bindDoStatement + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20405,10 +21318,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171 /* ArrayLiteralExpression */) { + else if (node.kind === 174 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192 /* SpreadElementExpression */) { + if (e.kind === 195 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20416,15 +21329,18 @@ var ts; } } } - else if (node.kind === 172 /* ObjectLiteralExpression */) { + else if (node.kind === 175 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253 /* PropertyAssignment */) { + if (p.kind === 256 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254 /* ShorthandPropertyAssignment */) { + else if (p.kind === 257 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 258 /* SpreadAssignment */) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -20476,9 +21392,9 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (node.left.kind === 174 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 177 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20489,7 +21405,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 176 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20499,9 +21415,11 @@ var ts; var postExpressionLabel = createBranchLabel(); bindCondition(node.condition, trueLabel, falseLabel); currentFlow = finishFlowLabel(trueLabel); + bind(node.questionToken); bind(node.whenTrue); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(falseLabel); + bind(node.colonToken); bind(node.whenFalse); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(postExpressionLabel); @@ -20520,7 +21438,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 211 /* ForInStatement */ || node.parent.parent.kind === 212 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20529,10 +21447,10 @@ 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 = node.expression; - while (expr.kind === 179 /* ParenthesizedExpression */) { + while (expr.kind === 182 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { + if (expr.kind === 183 /* FunctionExpression */ || expr.kind === 184 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20540,7 +21458,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 176 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20549,51 +21467,51 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 269 /* JSDocRecordType */: return 1 /* IsContainer */; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 269 /* JSDocFunctionType */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 273 /* JSDocFunctionType */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 256 /* SourceFile */: + case 260 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 149 /* Constructor */: - case 221 /* FunctionDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 150 /* Constructor */: + case 224 /* FunctionDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 252 /* CatchClause */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 228 /* CaseBlock */: + case 255 /* CatchClause */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 231 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 200 /* Block */: + case 203 /* 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 @@ -20630,41 +21548,41 @@ 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 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160 /* TypeLiteral */: - case 172 /* ObjectLiteralExpression */: - case 223 /* InterfaceDeclaration */: - case 265 /* JSDocRecordType */: - case 281 /* JSDocTypeLiteral */: + case 161 /* TypeLiteral */: + case 175 /* ObjectLiteralExpression */: + case 226 /* InterfaceDeclaration */: + case 269 /* JSDocRecordType */: + case 285 /* JSDocTypeLiteral */: // 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 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 269 /* JSDocFunctionType */: - case 224 /* TypeAliasDeclaration */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 273 /* JSDocFunctionType */: + case 227 /* TypeAliasDeclaration */: // 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 @@ -20685,11 +21603,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { + var body = node.kind === 260 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 260 /* SourceFile */ || body.kind === 230 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { + if (stat.kind === 240 /* ExportDeclaration */ || stat.kind === 239 /* ExportAssignment */) { return true; } } @@ -20782,7 +21700,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 258 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20794,7 +21712,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ + var currentKind = prop.kind === 256 /* PropertyAssignment */ || prop.kind === 257 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20816,10 +21734,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -20930,8 +21848,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 226 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 260 /* SourceFile */ && + blockScopeContainer.kind !== 229 /* 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. @@ -20997,7 +21915,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 > 139 /* LastToken */) { + if (node.kind > 140 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -21044,23 +21962,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 279 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 283 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 257 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -21084,123 +22002,139 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return checkStrictModeCatchClause(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return checkStrictModeWithStatement(node); - case 166 /* ThisType */: + case 167 /* ThisType */: seenThisKeyword = true; return; - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return checkTypePredicate(node); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 143 /* Parameter */: + case 144 /* Parameter */: return bindParameter(node); - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + if (node.dotDotDotToken && node.parent.kind === 171 /* ObjectBindingPattern */) { + emitFlags |= 32768 /* HasRestAttribute */; + } return bindVariableDeclarationOrBindingElement(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 266 /* JSDocRecordMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 270 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 280 /* JSDocPropertyTag */: + case 284 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 247 /* JsxSpreadAttribute */: - emitFlags |= 16384 /* HasJsxSpreadAttributes */; + case 258 /* SpreadAssignment */: + case 250 /* JsxSpreadAttribute */: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 175 /* ObjectLiteralExpression */ && + root.parent.kind === 191 /* BinaryExpression */ && + root.parent.operatorToken.kind === 57 /* EqualsToken */ && + root.parent.left === root) { + hasRest = true; + break; + } + root = root.parent; + } + emitFlags |= hasRest ? 32768 /* HasRestAttribute */ : 16384 /* HasSpreadAttribute */; return; - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* 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 ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 273 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 269 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return bindFunctionExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 230 /* ImportEqualsDeclaration */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return bindImportClause(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return bindExportDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return bindExportAssignment(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200 /* Block */: + case 203 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -21209,7 +22143,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166 /* ThisType */) { + if (parameterName && parameterName.kind === 167 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21232,7 +22166,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 239 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21242,17 +22176,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 256 /* SourceFile */) { + if (node.parent.kind !== 260 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_6 = node.parent; - if (!ts.isExternalModule(parent_6)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_6.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -21297,12 +22231,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* FunctionExpression */) { + if (container.kind === 224 /* FunctionDeclaration */ || container.kind === 183 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 149 /* Constructor */) { + else if (container.kind === 150 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21353,7 +22287,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21497,13 +22431,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 205 /* EmptyStatement */) || // report error on class declarations - node.kind === 222 /* ClassDeclaration */ || + node.kind === 225 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 229 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 228 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21517,7 +22451,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 /* VariableStatement */ || + (node.kind !== 204 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21537,56 +22471,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 143 /* Parameter */: + case 144 /* Parameter */: return computeParameter(node, subtreeFlags); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149 /* Constructor */: + case 150 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21600,21 +22534,21 @@ var ts; if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { - // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 + // If the this node contains a SpreadExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~545281365 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { case 96 /* SuperKeyword */: return true; - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -21626,31 +22560,34 @@ var ts; if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { // If the this node contains a SpreadElementExpression then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~545281365 /* ArrayLiteralOrCallOrNewExcludes */; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ - && (leftKind === 172 /* ObjectLiteralExpression */ - || leftKind === 171 /* ArrayLiteralExpression */)) { - // Destructuring assignments are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ObjectLiteralExpression */) { + // Destructuring object assignments with are ES2015 syntax + // and possibly ESNext if they contain rest + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 49152 /* AssertDestructuringAssignment */; + } + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 174 /* ArrayLiteralExpression */) { + // Destructuring assignments are ES2015 syntax. + transformFlags |= 3072 /* AssertES2015 */ | 49152 /* AssertDestructuringAssignment */; } else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. - transformFlags |= 192 /* AssertES2016 */; + transformFlags |= 768 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21662,21 +22599,25 @@ var ts; // syntax. if (node.questionToken || node.type - || subtreeFlags & 8192 /* ContainsDecorators */ + || subtreeFlags & 65536 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 4194304 /* ContainsParameterPropertyAssignments */; + } + // parameters with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 67108864 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 3072 /* AssertES2015 */ | 2097152 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~545262933 /* ParameterExcludes */; + return transformFlags & ~604001621 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21686,17 +22627,17 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 196 /* AsExpression */ - || expressionKind === 178 /* TypeAssertionExpression */) { + if (expressionKind === 199 /* AsExpression */ + || expressionKind === 181 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { - transformFlags |= 1024 /* DestructuringAssignment */; + if (expressionTransformFlags & 16384 /* DestructuringAssignment */) { + transformFlags |= 16384 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21707,47 +22648,47 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 768 /* AssertES2015 */; + transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */) + // An exported declaration may be TypeScript syntax, but is handled by the visitor + // for a namespace declaration. + if ((subtreeFlags & 4390912 /* TypeScriptClassSyntaxMask */) || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~539749717 /* ClassExcludes */; + return transformFlags & ~559895893 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + if (subtreeFlags & 4390912 /* TypeScriptClassSyntaxMask */ || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~539749717 /* ClassExcludes */; + return transformFlags & ~559895893 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. @@ -21758,27 +22699,27 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21788,11 +22729,11 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* ConstructorExcludes */; + return transformFlags & ~975983957 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and // overloads are TypeScript syntax. if (node.decorators @@ -21804,14 +22745,14 @@ var ts; } // An async method declaration is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; } // Currently, we only support generators that were originally async function bodies. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; + return transformFlags & ~975983957 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21824,7 +22765,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; + return transformFlags & ~975983957 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21832,10 +22773,10 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 16384 /* ContainsPropertyInitializer */; + transformFlags |= 131072 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -21847,11 +22788,7 @@ var ts; transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; - // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; - } + transformFlags = subtreeFlags | 268435456 /* ContainsHoistedDeclarationOrCompletion */; // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript // syntax. if (modifierFlags & 2270 /* TypeScriptModifier */ @@ -21861,13 +22798,17 @@ var ts; } // An async function declaration is ES2017 syntax. if (modifierFlags & 256 /* Async */) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // function declarations with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 2621440 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a @@ -21875,11 +22816,11 @@ var ts; // Currently we do not support transforming any other generator fucntions // down level. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592293205 /* FunctionExcludes */; + return transformFlags & ~980243797 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21892,13 +22833,17 @@ var ts; } // An async function expression is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // function expressions with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 2621440 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a @@ -21906,14 +22851,14 @@ var ts; // Currently we do not support transforming any other generator fucntions // down level. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592293205 /* FunctionExcludes */; + return transformFlags & ~980243797 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript // syntax. if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) @@ -21923,14 +22868,18 @@ var ts; } // An async arrow function is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // arrow functions with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 32768 /* ContainsLexicalThis */) { - transformFlags |= 65536 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 262144 /* ContainsLexicalThis */) { + transformFlags |= 524288 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592227669 /* ArrowFunctionExcludes */; + return transformFlags & ~979719509 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21939,24 +22888,28 @@ var ts; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. if (expressionKind === 96 /* SuperKeyword */) { - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + // A VariableDeclaration with an object binding pattern is ES2015 syntax + // and possibly ESNext syntax if it contains an object binding pattern + if (nameKind === 171 /* ObjectBindingPattern */) { + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } + else if (nameKind === 172 /* ArrayBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; } // Type annotations are TypeScript syntax. if (node.type) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21968,26 +22921,22 @@ var ts; } else { transformFlags = subtreeFlags; - // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & 1 /* Export */) { - transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; - } - if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */; + if (declarationListTransformFlags & 67108864 /* ContainsBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 33554432 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21996,18 +22945,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { - transformFlags |= 768 /* AssertES2015 */; + if (node.expression.transformFlags & 16384 /* DestructuringAssignment */) { + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -22016,29 +22965,29 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~574729557 /* ModuleExcludes */; + return transformFlags & ~839734613 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 268435456 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 67108864 /* ContainsBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; + transformFlags |= 3072 /* AssertES2015 */ | 33554432 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; + return transformFlags & ~604001621 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536874325 /* NodeExcludes */; + var excludeFlags = 536892757 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: // async/await is ES2017 syntax - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; break; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: @@ -22046,84 +22995,85 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: - case 197 /* NonNullExpression */: - case 129 /* ReadonlyKeyword */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: + case 200 /* NonNullExpression */: + case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: case 10 /* JsxText */: - case 245 /* JsxClosingElement */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - case 248 /* JsxExpression */: + case 248 /* JsxClosingElement */: + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: + case 251 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 83 /* ExportKeyword */: - // This node is both ES6 and TypeScript syntax. - transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; - break; - case 78 /* DefaultKeyword */: + case 212 /* ForOfStatement */: + // for-of might be ESNext if it has a rest destructuring + transformFlags |= 48 /* AssertESNext */; + // FALLTHROUGH case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 190 /* TemplateExpression */: - case 177 /* TaggedTemplateExpression */: - case 254 /* ShorthandPropertyAssignment */: - case 209 /* ForOfStatement */: + case 193 /* TemplateExpression */: + case 180 /* TaggedTemplateExpression */: + case 257 /* ShorthandPropertyAssignment */: + case 114 /* StaticKeyword */: // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; + transformFlags |= 3072 /* AssertES2015 */ | 134217728 /* ContainsYield */; break; case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 142 /* TypeParameter */: - case 145 /* PropertySignature */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 155 /* TypePredicate */: - case 156 /* TypeReference */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 156 /* TypePredicate */: + case 157 /* TypeReference */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 160 /* TypeQuery */: + case 161 /* TypeLiteral */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 2097152 /* ContainsComputedPropertyName */; - if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 16777216 /* ContainsComputedPropertyName */; + if (subtreeFlags & 262144 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -22132,70 +23082,86 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 1048576 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 192 /* SpreadElementExpression */: - // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 1048576 /* ContainsSpreadElementExpression */; + case 195 /* SpreadElement */: + case 258 /* SpreadAssignment */: + // This node is ES6 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; break; + case 173 /* BindingElement */: + if (node.dotDotDotToken) { + // this node is ES2015 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; + } case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; break; - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: - // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: + // These nodes are ES2015 or ES Next syntax. + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */ | 67108864 /* ContainsBindingPattern */; + } + else { + transformFlags |= 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } break; - case 144 /* Decorator */: + case 145 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 65536 /* ContainsDecorators */; break; - case 172 /* ObjectLiteralExpression */: - excludeFlags = 539110741 /* ObjectLiteralExcludes */; - if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { + case 175 /* ObjectLiteralExpression */: + excludeFlags = 554784085 /* ObjectLiteralExcludes */; + if (subtreeFlags & 16777216 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; + } + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + // If an ObjectLiteralExpression contains a spread element, then it + // is an ES next node. + transformFlags |= 48 /* AssertESNext */; } break; - case 171 /* ArrayLiteralExpression */: - case 176 /* NewExpression */: - excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { - // If the this node contains a SpreadElementExpression, then it is an ES6 + case 174 /* ArrayLiteralExpression */: + case 179 /* NewExpression */: + excludeFlags = 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + // If the this node contains a SpreadExpression, then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } break; - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 33554432 /* ContainsBlockScopedBinding */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 256 /* SourceFile */: - if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { - transformFlags |= 768 /* AssertES2015 */; + case 260 /* SourceFile */: + if (subtreeFlags & 524288 /* ContainsCapturedLexicalThis */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 212 /* ReturnStatement */: - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: - transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; + case 215 /* ReturnStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: + transformFlags |= 268435456 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -22210,54 +23176,54 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { + if (kind >= 156 /* FirstTypeNode */ && kind <= 170 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 171 /* ArrayLiteralExpression */: - return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; - case 226 /* ModuleDeclaration */: - return 574729557 /* ModuleExcludes */; - case 143 /* Parameter */: - return 545262933 /* ParameterExcludes */; - case 181 /* ArrowFunction */: - return 592227669 /* ArrowFunctionExcludes */; - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - return 592293205 /* FunctionExcludes */; - case 220 /* VariableDeclarationList */: - return 545262933 /* VariableDeclarationListExcludes */; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - return 539749717 /* ClassExcludes */; - case 149 /* Constructor */: - return 591760725 /* ConstructorExcludes */; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - return 591760725 /* MethodOrAccessorExcludes */; + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 174 /* ArrayLiteralExpression */: + return 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + case 229 /* ModuleDeclaration */: + return 839734613 /* ModuleExcludes */; + case 144 /* Parameter */: + return 604001621 /* ParameterExcludes */; + case 184 /* ArrowFunction */: + return 979719509 /* ArrowFunctionExcludes */; + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + return 980243797 /* FunctionExcludes */; + case 223 /* VariableDeclarationList */: + return 604001621 /* VariableDeclarationListExcludes */; + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + return 559895893 /* ClassExcludes */; + case 150 /* Constructor */: + return 975983957 /* ConstructorExcludes */; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return 975983957 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 142 /* TypeParameter */: - case 145 /* PropertySignature */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 172 /* ObjectLiteralExpression */: - return 539110741 /* ObjectLiteralExcludes */; + case 175 /* ObjectLiteralExpression */: + return 554784085 /* ObjectLiteralExcludes */; default: - return 536874325 /* NodeExcludes */; + return 536892757 /* NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -22275,25 +23241,63 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - /* @internal */ - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + /** + * Kinds of file that we are currently looking for. + * Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript. + */ + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; /** Only '.d.ts' */ + })(Extensions || (Extensions = {})); + /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + /** Create Resolved from a file with unknown extension. */ + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2 /* DtsOnly */: + case 0 /* TypeScript */: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1 /* JavaScript */: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -22302,19 +23306,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - // Use the main module for inferring types if no types package specified and the allowJs is set - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -22326,7 +23317,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -22355,11 +23345,11 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { + var parent_6 = ts.getDirectoryPath(currentDirectory); + if (parent_6 === currentDirectory) { break; } - currentDirectory = parent_7; + currentDirectory = parent_6; } return typeRoots; } @@ -22374,7 +23364,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -22402,18 +23391,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -22425,16 +23413,13 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { // check secondary locations if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -22450,9 +23435,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -22475,8 +23458,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -22593,15 +23576,15 @@ var ts; * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -22639,7 +23622,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -22658,7 +23641,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -22669,7 +23652,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -22697,9 +23680,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -22709,46 +23692,56 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -22760,9 +23753,9 @@ var ts; * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -22774,11 +23767,11 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing var directory = ts.getDirectoryPath(candidate); @@ -22786,9 +23779,18 @@ var ts; onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2 /* DtsOnly */: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0 /* TypeScript */: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1 /* JavaScript */: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { @@ -22813,19 +23815,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -22836,91 +23842,78 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - /* @internal */ - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(0 /* TypeScript */, moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - // Try to load source from the package - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package - return packageResult; - } - } - // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0 /* TypeScript */) { + // If we didn't find the file normally, look it up in @types. + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - // If we didn't find the file normally, look it up in @types. - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; /** Climb up parent directories looking for a module. */ - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -22931,6 +23924,23 @@ var ts; containingDirectory = parentPath; } } + /** + * LSHost may load a module from a global cache of typings. + * This is the minumum code needed to expose that functionality; the rest is in LSHost. + */ + /* @internal */ + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0 /* TypeScript */, moduleName, globalCache, failedLookupLocations, state, /*checkOneLevel*/ true) || + loadModuleFromNodeModules(1 /* JavaScript */, moduleName, globalCache, failedLookupLocations, state, /*checkOneLevel*/ true); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); /// /// @@ -23030,7 +24040,12 @@ var ts; getAmbientModules: getAmbientModules, getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter + isOptionalParameter: isOptionalParameter, + tryFindAmbientModuleWithoutAugmentations: function (moduleName) { + // we deliberately exclude augmentations + // since we are only interested in declarations of the module itself + return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); + } }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -23044,9 +24059,9 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var undefinedType = createIntrinsicType(2048 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 524288 /* ContainsWideningType */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 2097152 /* ContainsWideningType */, "undefined"); var nullType = createIntrinsicType(4096 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 /* Null */ | 524288 /* ContainsWideningType */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 /* Null */ | 2097152 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var trueType = createIntrinsicType(128 /* BooleanLiteral */, "true"); @@ -23056,13 +24071,17 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + emptyTypeLiteralSymbol.members = ts.createMap(); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.flags |= 2097152 /* ContainsAnyFunctionType */; + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -23221,6 +24240,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; /** Things we lazy load from the JSX namespace */ var jsxTypes = ts.createMap(); var JsxNames = { @@ -23250,6 +24271,21 @@ var ts; builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); return checker; + function getJsxNamespace() { + if (_jsxNamespace === undefined) { + _jsxNamespace = "React"; + if (compilerOptions.jsxFactory) { + _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + if (_jsxFactoryEntity) { + _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text; + } + } + else if (compilerOptions.reactNamespace) { + _jsxNamespace = compilerOptions.reactNamespace; + } + } + return _jsxNamespace; + } function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -23333,7 +24369,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 229 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 229 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23395,7 +24431,7 @@ var ts; var moduleNotFoundError = !ts.isInAmbientContext(moduleName.parent.parent) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; - var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError); + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); if (!mainModule) { return; } @@ -23440,7 +24476,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 256 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 260 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -23497,7 +24533,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 219 /* VariableDeclaration */ || + return declaration.kind !== 222 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23507,9 +24543,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201 /* VariableStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 204 /* VariableStatement */: + case 210 /* ForStatement */: + case 212 /* 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, container)) { @@ -23518,8 +24554,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23537,7 +24573,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 146 /* PropertyDeclaration */ && + current.parent.kind === 147 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23570,11 +24606,11 @@ 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 & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 277 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 143 /* Parameter */ || - lastLocation.kind === 142 /* TypeParameter */ + lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 143 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23583,9 +24619,9 @@ 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 === 143 /* Parameter */ || + lastLocation.kind === 144 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 143 /* Parameter */); + result.valueDeclaration.kind === 144 /* Parameter */); } } if (useResult) { @@ -23597,13 +24633,13 @@ var ts; } } switch (location.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 260 /* SourceFile */ || ts.isAmbientModule(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["default"]) { @@ -23626,7 +24662,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 242 /* ExportSpecifier */)) { break; } } @@ -23634,13 +24670,13 @@ var ts; break loop; } break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: // 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 @@ -23657,9 +24693,9 @@ var ts; } } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -23670,7 +24706,7 @@ var ts; } break loop; } - if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 196 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23686,9 +24722,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 226 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -23696,19 +24732,19 @@ var ts; } } break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23721,7 +24757,7 @@ var ts; } } break; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23730,7 +24766,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 === 143 /* Parameter */) { + if (location.parent && location.parent.kind === 144 /* Parameter */) { location = location.parent; } // @@ -23793,7 +24829,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 232 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23847,9 +24883,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23871,7 +24907,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 222 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23892,10 +24928,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 231 /* ImportDeclaration */) { + while (node && node.kind !== 234 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23905,7 +24941,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 244 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -23984,31 +25020,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_13 = specifier.propertyName || specifier.name; - if (name_13.text) { + var name_17 = specifier.propertyName || specifier.name; + if (name_17.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); + error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); } return symbol; } @@ -24030,19 +25066,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return getTargetOfImportClause(node); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -24089,11 +25125,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236 /* ExportAssignment */) { + if (node.kind === 239 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 239 /* ExportSpecifier */) { + else if (node.kind === 242 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -24115,13 +25151,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* 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 === 230 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 233 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -24141,9 +25177,9 @@ var ts; return undefined; } } - else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { - var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 141 /* QualifiedName */ || name.kind === 176 /* PropertyAccessExpression */) { + var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24168,30 +25204,30 @@ var ts; function resolveExternalModuleName(location, moduleReferenceExpression) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); } - function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral); + return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); } - function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode) { + function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReference); if (moduleName === undefined) { return; } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); - if (symbol) { - // merged symbol is module declaration symbol combined with all augmentations - return getMergedSymbol(symbol); - } + var ambientModule = tryFindAmbientModule(moduleName, /*withAugmentations*/ true); + if (ambientModule) { + return ambientModule; } + var isRelative = ts.isExternalModuleNameRelative(moduleName); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); + var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { // merged symbol is module declaration symbol combined with all augmentations @@ -24209,15 +25245,33 @@ var ts; return getMergedSymbol(pattern.symbol); } } + // May be an untyped module. If so, ignore resolutionDiagnostic. + if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (isForAugmentation) { + ts.Debug.assert(!!moduleNotFoundError); + var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; + error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + } + else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + } + // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. + return undefined; + } if (moduleNotFoundError) { // report errors only if it was requested - var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); - if (tsExtension) { - var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + if (resolutionDiagnostic) { + error(errorNode, resolutionDiagnostic, moduleName, resolvedModule.resolvedFileName); } else { - error(errorNode, moduleNotFoundError, moduleName); + var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } } return undefined; @@ -24350,7 +25404,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24426,11 +25480,11 @@ var ts; } } switch (location_1.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24471,7 +25525,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24510,7 +25564,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24525,10 +25579,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: continue; default: return false; @@ -24609,7 +25663,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -24650,12 +25704,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || - entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 176 /* PropertyAccessExpression */ || + entityName.parent.kind === 233 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24751,10 +25805,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 165 /* ParenthesizedType */) { + while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 227 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24762,7 +25816,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 /* ModuleBlock */ && + node.parent.kind === 230 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24776,10 +25830,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return "(Anonymous class)"; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24854,9 +25908,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -24918,31 +25972,8 @@ var ts; // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } - else if (!(flags & 512 /* InTypeAlias */) && - (getObjectFlags(type) & 16 /* Anonymous */ && !type.target || type.flags & 196608 /* UnionOrIntersection */) && - type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && (getObjectFlags(type) & 16 /* Anonymous */ || type.flags & 196608 /* UnionOrIntersection */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // We emit inferred type as type-alias if type is not in type-alias declaration, existed accessible alias-symbol, type is anonymous or union or intersection. - // However, if the type is an anonymous type with type arguments, we need to perform additional check. - // 1) No type arguments, just emit type-alias as is - // 2) Existed type arguments, check if the type arguments full fill all type parameters of the alias-symbol by - // checking whether the target's aliasTypeArguments has the same size as type's aliasTypeArguments: - // i.e - // type Foo = { - // foo(): Foo - // }; - // function foo() { - // return {} as Foo; - // } - // Should be emitted as - // declare type Foo = { - // foo(): Foo; - // }; - // declare function foo(): Foo; - // Otherwise type-alias is point to another generic type-alias then don't write it using alias symbol - // export type Bar = () => [X, Y]; - // export type Foo = Bar; - // export const y = (x: Foo) => 1 // this should be emit as "export declare const y: (x: () => [any, string]) => number;" var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } @@ -24955,6 +25986,17 @@ var ts; else if (type.flags & 96 /* StringOrNumberLiteral */) { writer.writeStringLiteral(literalTypeToString(type)); } + else if (type.flags & 262144 /* Index */) { + writer.writeKeyword("keyof"); + writeSpace(writer); + writeType(type.type, 64 /* InElementType */); + } + else if (type.flags & 524288 /* IndexedAccess */) { + writeType(type.objectType, 64 /* InElementType */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeType(type.indexType, 0 /* None */); + writePunctuation(writer, 21 /* CloseBracketToken */); + } else { // Should never get here // { ... } @@ -25018,14 +26060,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -25061,9 +26103,7 @@ var ts; else if (ts.contains(symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); - // We only want to use type-alias here if the typeAlias is not a generic one. (i.e it doesn't have a target type) - // If it is a generic type-alias just write out "any" - if (typeAlias && !type.target) { + if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } @@ -25093,7 +26133,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; + return declaration.parent.kind === 260 /* SourceFile */ || declaration.parent.kind === 230 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -25110,7 +26150,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } writePunctuation(writer, 20 /* OpenBracketToken */); @@ -25128,7 +26168,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -25185,6 +26225,12 @@ var ts; writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, 17 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); @@ -25197,8 +26243,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -25221,9 +26267,6 @@ var ts; writer.writeLine(); } } - writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -25262,12 +26305,12 @@ var ts; } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 171 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 172 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -25281,7 +26324,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 173 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55 /* ColonToken */); @@ -25411,75 +26454,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170 /* BindingElement */: + case 173 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 221 /* FunctionDeclaration */: - case 225 /* EnumDeclaration */: - case 230 /* ImportEqualsDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 224 /* FunctionDeclaration */: + case 228 /* EnumDeclaration */: + case 233 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_9 = 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 !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 233 /* ImportEqualsDeclaration */ && parent_9.kind !== 260 /* SourceFile */ && ts.isInAmbientContext(parent_9))) { + return isGlobalSourceFile(parent_9); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_10); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + return isDeclarationVisible(parent_9); + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.getModifierFlags(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 const it fall into next case statement - case 149 /* Constructor */: - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 154 /* IndexSignature */: - case 143 /* Parameter */: - case 227 /* ModuleBlock */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 156 /* TypeReference */: - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: + case 150 /* Constructor */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 155 /* IndexSignature */: + case 144 /* Parameter */: + case 230 /* ModuleBlock */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 157 /* TypeReference */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: return false; // Type parameters are always visible - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 256 /* SourceFile */: - case 229 /* NamespaceExportDeclaration */: + case 260 /* SourceFile */: + case 232 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return false; default: return false; @@ -25488,10 +26531,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 239 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 239 /* ExportSpecifier */) { + else if (node.parent.kind === 242 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25584,12 +26627,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219 /* VariableDeclaration */: - case 220 /* VariableDeclarationList */: - case 235 /* ImportSpecifier */: - case 234 /* NamedImports */: - case 233 /* NamespaceImport */: - case 232 /* ImportClause */: + case 222 /* VariableDeclaration */: + case 223 /* VariableDeclarationList */: + case 238 /* ImportSpecifier */: + case 237 /* NamedImports */: + case 236 /* NamespaceImport */: + case 235 /* ImportClause */: node = node.parent; break; default: @@ -25622,22 +26665,30 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70 /* Identifier */: - return name.text; - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return name.text; - case 141 /* ComputedPropertyName */: - if (ts.isStringOrNumericLiteral(name.expression.kind)) { - return name.expression.text; - } - } - return undefined; - } function isComputedNonLiteralName(name) { - return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + } + function getRestType(source, properties, symbol) { + ts.Debug.assert(!!(source.flags & 32768 /* Object */), "Rest types only support object types right now."); + var members = ts.createMap(); + var names = ts.createMap(); + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var name_18 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_18)] = true; + } + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + var inNamesToRemove = prop.name in names; + var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); + var isMethod = prop.flags & 8192 /* Method */; + var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + members[prop.name] = prop; + } + } + var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); + var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); + return createAnonymousType(symbol, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25657,25 +26708,41 @@ var ts; return parentType; } var type; - if (pattern.kind === 168 /* ObjectBindingPattern */) { - // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_14 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_14)) { - // computed properties with non-literal names are treated as 'any' - return anyType; + if (pattern.kind === 171 /* ObjectBindingPattern */) { + if (declaration.dotDotDotToken) { + if (!(parentType.flags & 32768 /* Object */)) { + error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); + return unknownType; + } + var literalMembers = []; + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 197 /* OmittedExpression */ && !element.dotDotDotToken) { + literalMembers.push(element.propertyName || element.name); + } + } + type = getRestType(parentType, literalMembers, declaration.symbol); } - if (declaration.initializer) { - getContextualType(declaration.initializer); - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var text = getTextOfPropertyName(name_14); - type = getTypeOfPropertyOfType(parentType, text) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); - return unknownType; + else { + // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) + var name_19 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_19)) { + // computed properties with non-literal names are treated as 'any' + return anyType; + } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } + // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, + // or otherwise the type of the string index signature. + var text = ts.getTextOfPropertyName(name_19); + type = getTypeOfPropertyOfType(parentType, text) || + isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || + getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); + return unknownType; + } } } else { @@ -25683,7 +26750,11 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false); - if (!declaration.dotDotDotToken) { + if (declaration.dotDotDotToken) { + // Rest element has an array type with the same element type as the parent type + type = createArrayType(elementType); + } + else { // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -25699,10 +26770,6 @@ var ts; return unknownType; } } - else { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); - } } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. @@ -25725,16 +26792,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 219 /* VariableDeclaration */ && - declaration.parent.kind === 220 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 201 /* VariableStatement */) { + if (declaration.kind === 222 /* VariableDeclaration */ && + declaration.parent.kind === 223 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 204 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 143 /* Parameter */) { + else if (declaration.kind === 144 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25750,14 +26817,14 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 174 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. @@ -25767,10 +26834,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 208 /* ForInStatement */) { + if (declaration.parent.parent.kind === 211 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 209 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 212 /* 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, @@ -25784,7 +26851,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + if (declaration.kind === 222 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -25797,11 +26864,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 143 /* Parameter */) { + if (declaration.kind === 144 /* Parameter */) { 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 === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); + if (func.kind === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25831,7 +26898,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 254 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 257 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -25862,12 +26929,12 @@ var ts; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { - // do not include computed properties in the implied type + if (isComputedNonLiteralName(name) || e.dotDotDotToken) { + // do not include computed properties or rests in the implied type hasComputedProperties = true; return; } - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -25907,7 +26974,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 /* ObjectBindingPattern */ + return pattern.kind === 171 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25929,7 +26996,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 253 /* PropertyAssignment */) { + if (declaration.kind === 256 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -25946,7 +27013,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25962,10 +27029,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 236 /* ExportAssignment */) { + if (declaration.kind === 239 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 2097152 /* JavaScriptFile */ && declaration.kind === 284 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -25978,16 +27045,16 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 188 /* BinaryExpression */ || - declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { + if (declaration.kind === 191 /* BinaryExpression */ || + declaration.kind === 176 /* PropertyAccessExpression */ && declaration.parent.kind === 191 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 191 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -26015,7 +27082,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150 /* GetAccessor */) { + if (accessor.kind === 151 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -26035,9 +27102,9 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); - if (getter && getter.flags & 1048576 /* JavaScriptFile */) { + var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + if (getter && getter.flags & 2097152 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -26080,7 +27147,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); error(getter_1, 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)); } } @@ -26091,7 +27158,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -26187,9 +27254,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || - node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || - node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { + if (node.kind === 225 /* ClassDeclaration */ || node.kind === 196 /* ClassExpression */ || + node.kind === 224 /* FunctionDeclaration */ || node.kind === 183 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */ || node.kind === 184 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -26199,7 +27266,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, 223 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 226 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -26208,8 +27275,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || - node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 226 /* InterfaceDeclaration */ || node.kind === 225 /* ClassDeclaration */ || + node.kind === 196 /* ClassExpression */ || node.kind === 227 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26352,7 +27419,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 226 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26384,7 +27451,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 /* InterfaceDeclaration */) { + if (declaration.kind === 226 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26442,7 +27509,7 @@ var ts; return unknownType; } var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 283 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -26453,7 +27520,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 227 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26479,14 +27546,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 189 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225 /* EnumDeclaration */) { + if (declaration.kind === 228 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26514,7 +27581,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225 /* EnumDeclaration */) { + if (declaration.kind === 228 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26552,7 +27619,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26606,19 +27673,19 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: - case 128 /* NeverKeyword */: - case 167 /* LiteralType */: + case 129 /* NeverKeyword */: + case 170 /* LiteralType */: return true; - case 161 /* ArrayType */: + case 162 /* ArrayType */: return isIndependentType(node.elementType); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26631,7 +27698,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26652,12 +27719,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26725,8 +27792,8 @@ var ts; else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); + constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } @@ -26788,7 +27855,7 @@ var ts; var baseSig = baseSignatures_1[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -26893,6 +27960,9 @@ var ts; function intersectIndexInfos(info1, info2) { return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); } + function unionSpreadIndexInfos(info1, info2) { + return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { // The members and properties collections are empty for intersection types. To get all properties of an // intersection type use getPropertiesOfType (only the language service uses this). @@ -26913,8 +27983,8 @@ var ts; var symbol = type.symbol; if (type.target) { var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); - var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0 /* String */), type.mapper); var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1 /* Number */), type.mapper); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -27026,7 +28096,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 196608 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 /* UnionOrIntersection */ ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } /** * The apparent type of a type parameter is the base constraint instantiated with the type parameter @@ -27048,22 +28120,13 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* TypeParameter */) { - type = getApparentTypeOfTypeParameter(type); - } - if (type.flags & 34 /* StringLike */) { - type = globalStringType; - } - else if (type.flags & 340 /* NumberLike */) { - type = globalNumberType; - } - else if (type.flags & 136 /* BooleanLike */) { - type = globalBooleanType; - } - else if (type.flags & 512 /* ESSymbol */) { - type = getGlobalESSymbolType(); - } - return type; + var t = type.flags & 16384 /* TypeParameter */ ? getApparentTypeOfTypeParameter(type) : type; + return t.flags & 34 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 262144 /* Index */ ? stringOrNumberType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -27227,7 +28290,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -27257,8 +28320,8 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 1048576 /* JavaScriptFile */) { - if (node.type && node.type.kind === 268 /* JSDocOptionalType */) { + if (node.flags & 2097152 /* JavaScriptFile */) { + if (node.type && node.type.kind === 272 /* JSDocOptionalType */) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -27267,11 +28330,19 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 272 /* JSDocOptionalType */; } } } } + function tryFindAmbientModule(moduleName, withAugmentations) { + if (ts.isExternalModuleNameRelative(moduleName)) { + return undefined; + } + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + // merged symbol is module declaration symbol combined with all augmentations + return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; + } function isOptionalParameter(node) { if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) { return true; @@ -27329,7 +28400,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167 /* LiteralType */) { + if (param.type && param.type.kind === 170 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -27343,10 +28414,10 @@ 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 === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && + if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; + var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27358,14 +28429,14 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - var classType = declaration.kind === 149 /* Constructor */ ? + var classType = declaration.kind === 150 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -27382,7 +28453,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -27390,8 +28461,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); + if (declaration.kind === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27405,20 +28476,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 273 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -27489,6 +28560,11 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); + var id = getTypeListId(typeArguments); + return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + } + function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); } function getErasedSignature(signature) { @@ -27505,7 +28581,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27519,7 +28595,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27546,7 +28622,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27579,7 +28655,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27616,7 +28692,7 @@ var ts; result |= type.flags; } } - return result & 3670016 /* PropagatingFlags */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -27692,11 +28768,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: return node.typeName; - case 267 /* JSDocTypeReference */: + case 271 /* JSDocTypeReference */: return node.name; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27722,7 +28798,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 267 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 271 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -27735,14 +28811,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267 /* JSDocTypeReference */) { + if (node.kind === 271 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 156 /* TypeReference */ + var typeNameOrExpression = node.kind === 157 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27777,9 +28853,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: return declaration; } } @@ -27934,7 +29010,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096 /* Null */) typeSet.containsNull = true; - if (!(flags & 524288 /* ContainsWideningType */)) + if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192 /* Never */)) { @@ -28012,7 +29088,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 /* StringLiteral */ && types.containsString || t.flags & 64 /* NumberLiteral */ && types.containsNumber || - t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 262144 /* FreshLiteral */ && containsType(types, t.regularType); + t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 1048576 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -28109,7 +29185,7 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var _loop_1 = function (i) { + var _loop_2 = function (i) { var type_1 = types[i]; if (type_1.flags & 65536 /* Union */) { return { value: getUnionType(ts.map(type_1.types, function (t) { return getIntersectionType(ts.replaceElement(types, i, t)); }), @@ -28117,7 +29193,7 @@ var ts; } }; for (var i = 0; i < types.length; i++) { - var state_2 = _loop_1(i); + var state_2 = _loop_2(i); if (typeof state_2 === "object") return state_2.value; } @@ -28147,26 +29223,223 @@ var ts; } return links.resolvedType; } + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144 /* Index */); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return ts.startsWith(prop.name, "__@") ? neverType : getLiteralTypeForText(32 /* StringLiteral */, ts.unescapeIdentifier(prop.name)); + } + function getLiteralTypeFromPropertyNames(type) { + return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName)); + } + function getIndexType(type) { + return type.flags & 16384 /* TypeParameter */ ? getIndexTypeForTypeParameter(type) : + type.flags & 1 /* Any */ || getIndexInfoOfType(type, 0 /* String */) ? stringOrNumberType : + getIndexInfoOfType(type, 1 /* Number */) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getLiteralTypeFromPropertyNames(type); + } + function getTypeFromTypeOperatorNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexType(getTypeFromTypeNodeNoAlias(node.type)); + } + return links.resolvedType; + } + function createIndexedAccessType(objectType, indexType) { + var type = createType(524288 /* IndexedAccess */); + type.objectType = objectType; + type.indexType = indexType; + return type; + } + function getIndexedAccessTypeForTypeParameter(objectType, indexType) { + var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); + return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); + } + function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { + var accessExpression = accessNode && accessNode.kind === 177 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? + indexType.text : + accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? + ts.getPropertyNameForKnownSymbolName(accessExpression.argumentExpression.name.text) : + undefined; + if (propName) { + var prop = getPropertyOfType(objectType, propName); + if (prop) { + if (accessExpression) { + if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { + error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); + return unknownType; + } + if (cacheSymbol) { + getNodeLinks(accessNode).resolvedSymbol = prop; + } + } + return getTypeOfSymbol(prop); + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */)) { + if (isTypeAny(objectType)) { + return anyType; + } + var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + getIndexInfoOfType(objectType, 0 /* String */) || + undefined; + if (indexInfo) { + if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + return unknownType; + } + return indexInfo.type; + } + if (accessExpression && !isConstEnumObjectType(objectType)) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (getIndexTypeOfType(objectType, 1 /* Number */)) { + error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } + } + return anyType; + } + } + if (accessNode) { + var indexNode = accessNode.kind === 177 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { + error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); + } + else if (indexType.flags & (2 /* String */ | 4 /* Number */)) { + error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); + } + else { + error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); + } + } + return unknownType; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + if (indexType.flags & 16384 /* TypeParameter */) { + if (!isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + if (accessNode) { + error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); + } + return unknownType; + } + return getIndexedAccessTypeForTypeParameter(objectType, indexType); + } + var apparentType = getApparentType(objectType); + if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8190 /* Primitive */)) { + var propTypes = []; + for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, /*cacheSymbol*/ false); + if (propType === unknownType) { + return unknownType; + } + propTypes.push(propType); + } + return getUnionType(propTypes); + } + return getPropertyTypeForIndexType(apparentType, indexType, accessNode, /*cacheSymbol*/ true); + } + function getTypeFromIndexedAccessTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexedAccessType(getTypeFromTypeNodeNoAlias(node.objectType), getTypeFromTypeNodeNoAlias(node.indexType), node); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { var links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers - var type = createObjectType(16 /* Anonymous */, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; - links.resolvedType = type; + if (ts.isEmpty(node.symbol.members) && !aliasSymbol && !aliasTypeArguments) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16 /* Anonymous */, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = type; + } } return links.resolvedType; } + /** + * Since the source of spread types are object literals, which are not binary, + * this function should be called in a left folding style, with left = previous result of getSpreadType + * and right = the new element to be spread. + */ + function getSpreadType(left, right, isFromObjectLiteral) { + ts.Debug.assert(!!(left.flags & (32768 /* Object */ | 1 /* Any */)) && !!(right.flags & (32768 /* Object */ | 1 /* Any */)), "Only object types may be spread."); + if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + return anyType; + } + var members = ts.createMap(); + var skippedPrivateMembers = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + if (left === emptyObjectType) { + // for the first spread element, left === emptyObjectType, so take the right's string indexer + stringIndexInfo = getIndexInfoOfType(right, 0 /* String */); + numberIndexInfo = getIndexInfoOfType(right, 1 /* Number */); + } + else { + stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0 /* String */), getIndexInfoOfType(right, 0 /* String */)); + numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1 /* Number */), getIndexInfoOfType(right, 1 /* Number */)); + } + for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { + var rightProp = _a[_i]; + // we approximate own properties as non-methods plus methods that are inside the object literal + var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; + var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + skippedPrivateMembers[rightProp.name] = true; + } + else if (isOwnProperty && !isSetterWithoutGetter) { + members[rightProp.name] = rightProp; + } + } + for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { + var leftProp = _c[_b]; + if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) + || leftProp.name in skippedPrivateMembers) { + continue; + } + if (leftProp.name in members) { + var rightProp = members[leftProp.name]; + var rightType = getTypeOfSymbol(rightProp); + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); + var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var result = createSymbol(flags, leftProp.name); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.leftSpread = leftProp; + result.rightSpread = rightProp; + result.declarations = declarations; + result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); + members[leftProp.name] = result; + } + } + else { + members[leftProp.name] = leftProp; + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 262144 /* FreshLiteral */)) { + if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 1048576 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 262144 /* FreshLiteral */, type.text); + var freshType = createLiteralType(type.flags | 1048576 /* FreshLiteral */, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -28175,7 +29448,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 262144 /* FreshLiteral */ ? type.regularType : type; + return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; @@ -28207,9 +29480,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 226 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -28229,81 +29502,85 @@ var ts; function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { case 118 /* AnyKeyword */: - case 258 /* JSDocAllType */: - case 259 /* JSDocUnknownType */: + case 262 /* JSDocAllType */: + case 263 /* JSDocUnknownType */: return anyType; - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: return stringType; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; - case 128 /* NeverKeyword */: + case 129 /* NeverKeyword */: return neverType; - case 283 /* JSDocNullKeyword */: + case 287 /* JSDocNullKeyword */: return nullType; - case 284 /* JSDocUndefinedKeyword */: + case 288 /* JSDocUndefinedKeyword */: return undefinedType; - case 285 /* JSDocNeverKeyword */: + case 289 /* JSDocNeverKeyword */: return neverType; - case 166 /* ThisType */: + case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 167 /* LiteralType */: + case 170 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 282 /* JSDocLiteralType */: + case 286 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 156 /* TypeReference */: - case 267 /* JSDocTypeReference */: + case 157 /* TypeReference */: + case 271 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return booleanType; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 161 /* ArrayType */: - case 260 /* JSDocArrayType */: + case 162 /* ArrayType */: + case 264 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 163 /* UnionType */: - case 261 /* JSDocUnionType */: + case 164 /* UnionType */: + case 265 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 165 /* ParenthesizedType */: - case 263 /* JSDocNullableType */: - case 264 /* JSDocNonNullableType */: - case 271 /* JSDocConstructorType */: - case 272 /* JSDocThisType */: - case 268 /* JSDocOptionalType */: + case 166 /* ParenthesizedType */: + case 267 /* JSDocNullableType */: + case 268 /* JSDocNonNullableType */: + case 275 /* JSDocConstructorType */: + case 276 /* JSDocThisType */: + case 272 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 265 /* JSDocRecordType */: + case 269 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 273 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 168 /* TypeOperator */: + return getTypeFromTypeOperatorNode(node); + case 169 /* IndexedAccessType */: + return getTypeFromIndexedAccessTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262 /* JSDocTupleType */: + case 266 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 270 /* JSDocVariadicType */: + case 274 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -28320,6 +29597,12 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -28342,7 +29625,6 @@ var ts; count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; - mapper.targetTypes = targets; return mapper; } function createTypeEraser(sources) { @@ -28454,11 +29736,14 @@ var ts; result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); mapper.instantiations[type.id] = result; return result; } function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { + if (!(symbol.declarations && symbol.declarations.length)) { + return false; + } var mappedTypes = mapper.mappedTypes; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first @@ -28466,23 +29751,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28492,15 +29777,15 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 226 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: + case 229 /* ModuleDeclaration */: + case 260 /* SourceFile */: return false; } node = node.parent; @@ -28526,14 +29811,20 @@ var ts; instantiateAnonymousType(type, mapper) : type; } if (type.objectFlags & 4 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (type.flags & 131072 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 262144 /* Index */) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288 /* IndexedAccess */) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } } return type; @@ -28544,27 +29835,27 @@ 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 !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -28579,7 +29870,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 184 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -28856,10 +30147,10 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 262144 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { @@ -28872,7 +30163,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 245760 /* StructuredOrTypeParameter */ || target.flags & 245760 /* StructuredOrTypeParameter */) { + if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -28919,9 +30210,15 @@ var ts; targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); } if (!message) { - message = relation === comparableRelation ? - ts.Diagnostics.Type_0_is_not_comparable_to_type_1 : - ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + if (relation === comparableRelation) { + message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1; + } + else if (sourceType === targetType) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; + } + else { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + } } reportError(message, sourceType, targetType); } @@ -28941,10 +30238,10 @@ var ts; // Ternary.False if they are not related. function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 262144 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -28955,7 +30252,7 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (getObjectFlags(source) & 64 /* ObjectLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (getObjectFlags(source) & 64 /* ObjectLiteral */ && source.flags & 1048576 /* FreshLiteral */) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -29013,6 +30310,26 @@ var ts; return result; } } + if (target.flags & 16384 /* TypeParameter */) { + // Given a type parameter K with a constraint keyof T, a type S is + // assignable to K if S is assignable to keyof T. + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144 /* Index */) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + } + } + else if (target.flags & 262144 /* Index */) { + // Given a type parameter T with a constraint C, a type S is assignable to + // keyof T if S is assignable to keyof C. + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } if (source.flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(source); if (!constraint || constraint.flags & 1 /* Any */) { @@ -29305,8 +30622,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 64 /* ObjectLiteral */); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var targetProp = properties_3[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -29799,8 +31116,8 @@ var ts; type; } function getWidenedLiteralType(type) { - return type.flags & 32 /* StringLiteral */ && type.flags & 262144 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 262144 /* FreshLiteral */ ? numberType : + return type.flags & 32 /* StringLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? stringType : + type.flags & 64 /* NumberLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : @@ -29895,7 +31212,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(getObjectFlags(type) & 64 /* ObjectLiteral */ && type.flags & 262144 /* FreshLiteral */)) { + if (!(getObjectFlags(type) & 64 /* ObjectLiteral */ && type.flags & 1048576 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -29905,7 +31222,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~262144 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~1048576 /* FreshLiteral */; regularNew.objectFlags |= 64 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; @@ -29923,7 +31240,7 @@ var ts; return type.flags & 6144 /* Nullable */ ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 1572864 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & 6144 /* Nullable */) { return anyType; } @@ -29972,7 +31289,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 524288 /* ContainsWideningType */) { + if (t.flags & 2097152 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -29986,25 +31303,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 143 /* Parameter */: + case 144 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 170 /* BindingElement */: + case 173 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -30017,7 +31334,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288 /* ContainsWideningType */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -30145,7 +31462,7 @@ var ts; // it as an inference candidate. Hopefully, a better candidate will come along that does // not contain anyFunctionType when we come back to this argument for its second round // of inference. - if (source.flags & 2097152 /* ContainsAnyFunctionType */) { + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -30244,8 +31561,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -30323,7 +31640,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 8190 /* Primitive */); + return constraint && maybeTypeOfKind(constraint, 8190 /* Primitive */ | 262144 /* Index */); } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; @@ -30393,10 +31710,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return true; case 70 /* Identifier */: - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: node = node.parent; continue; default: @@ -30417,7 +31734,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 176 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30428,7 +31745,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -30437,19 +31754,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && + (target.kind === 222 /* VariableDeclaration */ || target.kind === 173 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 173 /* PropertyAccessExpression */: - return target.kind === 173 /* PropertyAccessExpression */ && + case 176 /* PropertyAccessExpression */: + return target.kind === 176 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173 /* PropertyAccessExpression */) { + while (source.kind === 176 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30462,7 +31779,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 /* PropertyAccessExpression */ && + return target.kind === 176 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -30470,7 +31787,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 176 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30500,7 +31817,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 176 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30616,7 +31933,7 @@ var ts; return type; } function getTypeOfDestructuredProperty(type, name) { - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || @@ -30627,19 +31944,19 @@ var ts; checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType; } - function getTypeOfDestructuredSpreadElement(type) { + function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 174 /* ArrayLiteralExpression */ || node.parent.kind === 256 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } - function getAssignedTypeOfSpreadElement(node) { - return getTypeOfDestructuredSpreadElement(getAssignedType(node.parent)); + function getAssignedTypeOfSpreadExpression(node) { + return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent)); } function getAssignedTypeOfPropertyAssignment(node) { return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name); @@ -30650,21 +31967,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return stringType; - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return undefinedType; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192 /* SpreadElementExpression */: - return getAssignedTypeOfSpreadElement(parent); - case 253 /* PropertyAssignment */: + case 195 /* SpreadElement */: + return getAssignedTypeOfSpreadExpression(parent); + case 256 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -30672,11 +31989,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 /* ObjectBindingPattern */ ? + var type = pattern.kind === 171 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : - getTypeOfDestructuredSpreadElement(parentType); + getTypeOfDestructuredSpreadExpression(parentType); return getTypeWithDefault(type, node.initializer); } function getTypeOfInitializer(node) { @@ -30690,35 +32007,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208 /* ForInStatement */) { + if (node.parent.parent.kind === 211 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.parent.kind === 212 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 /* VariableDeclaration */ ? + return node.kind === 222 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? + return node.kind === 222 /* VariableDeclaration */ || node.kind === 173 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 /* VariableDeclaration */ && node.initializer && + return node.kind === 222 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + node.kind !== 173 /* BindingElement */ && node.parent.kind === 191 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -30730,13 +32047,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 179 /* ParenthesizedExpression */ || - parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 182 /* ParenthesizedExpression */ || + parent.kind === 191 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 191 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 252 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -30872,11 +32189,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 176 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 178 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 177 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.kind === 191 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -30885,7 +32202,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 246783 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -30899,7 +32216,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 = getObjectFlags(evolvedType) & 128 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 200 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -30948,7 +32265,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 176 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30974,7 +32291,7 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { + if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -31002,7 +32319,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 /* CallExpression */ ? + var expr = node.kind === 178 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -31010,7 +32327,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 128 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 178 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -31165,7 +32482,7 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 /* PropertyAccessExpression */ && + return expr.kind === 176 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -31199,10 +32516,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 === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 186 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 186 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -31400,10 +32717,10 @@ var ts; } } else { - var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { + var invokedExpression = ts.skipParentheses(callExpression.expression); + if (invokedExpression.kind === 177 /* ElementAccessExpression */ || invokedExpression.kind === 176 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -31420,15 +32737,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -31460,19 +32777,13 @@ var ts; // binder), we simply return the declared type of the symbol. return getTypeOfSymbol(symbol); } - function skipParenthesizedNodes(expression) { - while (expression.kind === 179 /* ParenthesizedExpression */) { - expression = expression.expression; - } - return expression; - } function getControlFlowContainer(node) { while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 227 /* ModuleBlock */ || - node.kind === 256 /* SourceFile */ || - node.kind === 146 /* PropertyDeclaration */) { + node.kind === 230 /* ModuleBlock */ || + node.kind === 260 /* SourceFile */ || + node.kind === 147 /* PropertyDeclaration */) { return node; } } @@ -31504,7 +32815,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { symbol.isAssigned = true; } } @@ -31518,6 +32829,9 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return unknownType; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects @@ -31527,16 +32841,17 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 184 /* 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.hasModifier(container, 256 /* Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 262144 /* AwaitContext */) { + if (node.flags & 524288 /* AwaitContext */) { getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } + return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -31548,7 +32863,7 @@ var ts; // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. if (languageVersion === 2 /* ES2015 */ - && declaration_1.kind === 222 /* ClassDeclaration */ + && declaration_1.kind === 225 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31560,14 +32875,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193 /* ClassExpression */) { + else if (declaration_1.kind === 196 /* 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 !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31582,23 +32897,34 @@ var ts; checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (!(localOrExportSymbol.flags & 3 /* Variable */)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + return unknownType; + } + if (isReadonlySymbol(localOrExportSymbol)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); + return unknownType; + } + } // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (!(localOrExportSymbol.flags & 3 /* Variable */) || ts.isAssignmentTarget(node) || !declaration) { + if (!(localOrExportSymbol.flags & 3 /* Variable */) || assignmentKind === 1 /* Definite */ || !declaration) { return type; } // 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 === 143 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // 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 === 180 /* FunctionExpression */ || - flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 183 /* FunctionExpression */ || + flowContainer.kind === 184 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -31626,7 +32952,7 @@ var ts; // Return the declared type to reduce follow-on errors return type; } - return flowType; + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { var current = node; @@ -31641,7 +32967,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 255 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -31666,8 +32992,8 @@ 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 (container.kind === 207 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && + if (container.kind === 210 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 223 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31681,7 +33007,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 179 /* ParenthesizedExpression */) { + while (current.parent.kind === 182 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31689,7 +33015,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 189 /* PrefixUnaryExpression */ || current.parent.kind === 190 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -31710,7 +33036,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { + if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31758,7 +33084,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 149 /* Constructor */) { + if (container.kind === 150 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31779,32 +33105,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 184 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* 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 225 /* EnumDeclaration */: + case 228 /* 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 149 /* Constructor */: + case 150 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31816,7 +33142,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 180 /* FunctionExpression */ && + if (container.kind === 183 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31853,28 +33179,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 269 /* JSDocFunctionType */) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 273 /* JSDocFunctionType */) { var jsDocFunctionType = typeTag.typeExpression.type; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 272 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 276 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 143 /* Parameter */) { + if (n.kind === 144 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 178 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 181 /* ArrowFunction */) { + while (container && container.kind === 184 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -31888,16 +33214,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 141 /* ComputedPropertyName */) { + if (current && current.kind === 142 /* 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 === 172 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 175 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31968,7 +33294,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31982,7 +33308,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (container.parent.kind === 175 /* 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 unknownType; @@ -32002,7 +33328,7 @@ var ts; } return unknownType; } - if (container.kind === 149 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 150 /* 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 unknownType; @@ -32017,7 +33343,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 === 149 /* Constructor */; + return container.kind === 150 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -32025,21 +33351,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 === 172 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 175 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 148 /* MethodDeclaration */ || - container.kind === 147 /* MethodSignature */ || - container.kind === 150 /* GetAccessor */ || - container.kind === 151 /* SetAccessor */; + return container.kind === 149 /* MethodDeclaration */ || + container.kind === 148 /* MethodSignature */ || + container.kind === 151 /* GetAccessor */ || + container.kind === 152 /* SetAccessor */; } else { - return container.kind === 148 /* MethodDeclaration */ || - container.kind === 147 /* MethodSignature */ || - container.kind === 150 /* GetAccessor */ || - container.kind === 151 /* SetAccessor */ || - container.kind === 146 /* PropertyDeclaration */ || - container.kind === 145 /* PropertySignature */ || - container.kind === 149 /* Constructor */; + return container.kind === 149 /* MethodDeclaration */ || + container.kind === 148 /* MethodSignature */ || + container.kind === 151 /* GetAccessor */ || + container.kind === 152 /* SetAccessor */ || + container.kind === 147 /* PropertyDeclaration */ || + container.kind === 146 /* PropertySignature */ || + container.kind === 150 /* Constructor */; } } } @@ -32047,7 +33373,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 184 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -32113,7 +33439,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 143 /* Parameter */) { + if (declaration.kind === 144 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -32124,11 +33450,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_15 = declaration.propertyName || declaration.name; + var name_20 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_15)) { - var text = getTextOfPropertyName(name_15); + !ts.isBindingPattern(name_20)) { + var text = ts.getTextOfPropertyName(name_20); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -32165,7 +33491,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -32176,8 +33502,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 149 /* Constructor */ || - functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { + functionDecl.kind === 150 /* Constructor */ || + functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -32199,7 +33525,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177 /* TaggedTemplateExpression */) { + if (template.parent.kind === 180 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -32327,13 +33653,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246 /* JsxAttribute */) { + if (attribute.kind === 249 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247 /* JsxSpreadAttribute */) { + else if (attribute.kind === 250 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -32371,41 +33697,41 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219 /* VariableDeclaration */: - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 173 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 181 /* ArrowFunction */: - case 212 /* ReturnStatement */: + case 184 /* ArrowFunction */: + case 215 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 198 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); + case 201 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 193 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return getContextualType(parent); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return getContextualType(parent); - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -32437,7 +33763,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; + return node.kind === 183 /* FunctionExpression */ || node.kind === 184 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -32456,7 +33782,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 !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -32512,7 +33838,7 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper.context; } - function checkSpreadElementExpression(node, contextualMapper) { + function checkSpreadExpression(node, contextualMapper) { // It is usually not safe to call checkExpressionCached if we can be contextually typing. // You can tell that we are contextually typing because of the contextualMapper parameter. // While it is true that a spread element can have a contextual type, it does not do anything @@ -32523,8 +33849,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 170 /* BindingElement */ && !!node.initializer) || - (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 173 /* BindingElement */ && !!node.initializer) || + (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -32533,7 +33859,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 195 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32557,7 +33883,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 195 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32572,7 +33898,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 172 /* ArrayBindingPattern */ || pattern.kind === 174 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32580,7 +33906,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194 /* OmittedExpression */) { + if (patternElement.kind !== 197 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32597,7 +33923,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 141 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -32665,9 +33991,11 @@ var ts; checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); var propertiesArray = []; + var spread = emptyObjectType; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 171 /* ObjectBindingPattern */ || contextualType.pattern.kind === 175 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32675,18 +34003,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 253 /* PropertyAssignment */ || - memberDecl.kind === 254 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 256 /* PropertyAssignment */ || + memberDecl.kind === 257 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253 /* PropertyAssignment */) { + if (memberDecl.kind === 256 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 148 /* MethodDeclaration */) { + else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 254 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 257 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -32694,8 +34022,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 === 253 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 254 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 256 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 257 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -32723,13 +34051,30 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 258 /* SpreadAssignment */) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + propertiesArray = []; + propertiesTable = ts.createMap(); + hasComputedStringProperty = false; + hasComputedNumberProperty = false; + typeFlags = 0; + } + var type = checkExpression(memberDecl.expression); + if (!(type.flags & (32768 /* Object */ | 1 /* Any */))) { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return unknownType; + } + spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + continue; + } else { // TypeScript 1.0 spec (April 2014) // A get accessor declaration is processed in the same manner as // 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 === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32759,19 +34104,33 @@ var ts; } } } - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 262144 /* FreshLiteral */; - result.flags |= 1048576 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 3670016 /* PropagatingFlags */); - result.objectFlags |= 64 /* ObjectLiteral */; - if (patternWithComputedProperties) { - result.objectFlags |= 256 /* ObjectLiteralPatternWithComputedProperties */; + if (spread !== emptyObjectType) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + } + spread.flags |= propagatedFlags; + spread.symbol = node.symbol; + return spread; } - if (inDestructuringPattern) { - result.pattern = node; + return createObjectLiteralType(); + function createObjectLiteralType() { + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + result.objectFlags |= 64 /* ObjectLiteral */; + if (patternWithComputedProperties) { + result.objectFlags |= 256 /* ObjectLiteralPatternWithComputedProperties */; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144 /* Nullable */)) { + propagatedFlags |= (result.flags & 14680064 /* PropagatingFlags */); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -32791,13 +34150,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: checkJsxExpression(child); break; - case 242 /* JsxElement */: + case 245 /* JsxElement */: checkJsxElement(child); break; - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32816,7 +34175,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 176 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32834,7 +34193,7 @@ var ts; var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); + var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); if (attributeType) { correspondingPropType = attributeType; } @@ -33148,10 +34507,10 @@ var ts; function checkJsxOpeningLikeElement(node) { checkGrammarJsxElement(node); checkJsxPreconditions(node); - // The reactNamespace symbol should be marked as 'used' so we don't incorrectly elide its import. And if there - // is no reactNamespace symbol in scope when targeting React emit, we should issue an error. + // 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 reactRefErr = compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; + var reactNamespace = getJsxNamespace(); var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked @@ -33169,11 +34528,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 246 /* JsxAttribute */) { + if (node.attributes[i].kind === 249 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 250 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -33203,7 +34562,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 147 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -33222,7 +34581,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? + var errorNode = node.kind === 176 /* PropertyAccessExpression */ || node.kind === 222 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -33233,7 +34592,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -33313,6 +34672,33 @@ var ts; function checkQualifiedName(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } + function reportNonexistentProperty(propNode, containingType) { + var errorInfo; + if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { + for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { + var subtype = _a[_i]; + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + function markPropertyAsReferenced(prop) { + if (prop && + noUnusedIdentifiers && + (prop.flags & 106500 /* ClassMember */) && + prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { + if (prop.flags & 16777216 /* Instantiated */) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -33330,47 +34716,32 @@ var ts; } return unknownType; } - if (noUnusedIdentifiers && - (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } + markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { + error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text); + return unknownType; + } + } // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 176 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; } - return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } + var flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 173 /* PropertyAccessExpression */ + var left = node.kind === 176 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -33387,7 +34758,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer.kind === 223 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -33409,14 +34780,14 @@ var ts; * that references a for-in variable for an object with numeric property names. */ function isForInVariableForNumericPropertyNames(expr) { - var e = skipParenthesizedNodes(expr); + var e = ts.skipParentheses(expr); if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 208 /* ForInStatement */ && + if (node.kind === 211 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -33430,10 +34801,11 @@ var ts; return false; } function checkIndexedAccess(node) { - // Grammar checking - if (!node.argumentExpression) { + var objectType = checkNonNullExpression(node.expression); + var indexExpression = node.argumentExpression; + if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 176 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 179 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -33443,101 +34815,18 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } + return unknownType; } - // Obtain base constraint such that we can bail out if the constraint is an unknown type - var objectType = getApparentType(checkNonNullExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); if (objectType === unknownType || objectType === silentNeverType) { return objectType; } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - // TypeScript 1.0 spec (April 2014): 4.10 Property Access - // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name - // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. - // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. - // See if we can index as a property. - if (node.argumentExpression) { - var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_16 !== undefined) { - var prop = getPropertyOfType(objectType, name_16); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - // Check for compatible indexer types. - var allowedNullableFlags = strictNullChecks ? 0 : 6144 /* Nullable */; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */ | allowedNullableFlags)) { - // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexInfo = getIndexInfoOfType(objectType, 1 /* Number */); - if (numberIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; - return numberIndexInfo.type; - } - } - // Try to use string indexing. - var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); - if (stringIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; - return stringIndexInfo.type; - } - // Fall back to any. - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, getIndexTypeOfType(objectType, 1 /* Number */) ? - ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number : - ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - // REVIEW: Users should know the type that was actually used. - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; + return getIndexedAccessType(objectType, indexType, node); } - /** - * If indexArgumentExpression is a string literal or number literal, returns its text. - * If indexArgumentExpression is a constant value, returns its string value. - * If indexArgumentExpression is a well known symbol, returns the property name corresponding - * to this symbol, as long as it is a proper symbol reference. - * Otherwise, returns undefined. - */ - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - /** - * A proper symbol reference requires the following: - * 1. The property access denotes a property that exists - * 2. The expression is of the form Symbol. - * 3. The property access is of the primitive type symbol. - * 4. Symbol in this context resolves to the global Symbol object - */ function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { // There is already an error, so no need to report one. @@ -33574,10 +34863,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 144 /* Decorator */) { + else if (node.kind !== 145 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33607,13 +34896,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_11 = signature.declaration && signature.declaration.parent; + var parent_10 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_10 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_10; index = cutoffIndex; } } @@ -33621,7 +34910,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_10; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33643,7 +34932,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 192 /* SpreadElementExpression */) { + if (arg && arg.kind === 195 /* SpreadElement */) { return i; } } @@ -33656,13 +34945,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190 /* TemplateExpression */) { + if (tagExpression.template.kind === 193 /* 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 templateExpression = tagExpression.template; @@ -33679,7 +34968,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 144 /* Decorator */) { + else if (node.kind === 145 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33688,7 +34977,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 179 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33772,7 +35061,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 197 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -33829,7 +35118,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 179 /* 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. @@ -33846,7 +35135,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 197 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); @@ -33868,12 +35157,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 178 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 173 /* PropertyAccessExpression */) { + if (callee.kind === 176 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 174 /* ElementAccessExpression */) { + else if (callee.kind === 177 /* ElementAccessExpression */) { return callee.expression; } } @@ -33889,16 +35178,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 190 /* TemplateExpression */) { + if (template.kind === 193 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144 /* Decorator */) { + else if (node.kind === 145 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -33923,19 +35212,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* 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. @@ -33945,7 +35234,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 143 /* Parameter */: + case 144 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33969,25 +35258,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -34014,21 +35303,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { node = node.parent; - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will @@ -34039,7 +35328,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -34065,21 +35354,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 146 /* PropertyDeclaration */) { + if (node.kind === 147 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -34111,10 +35400,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -34126,8 +35415,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 144 /* Decorator */ || - (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { + if (node.kind === 145 /* Decorator */ || + (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -34136,11 +35425,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -34149,8 +35438,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 144 /* Decorator */; + var isTaggedTemplate = node.kind === 180 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 145 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -34221,7 +35510,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 = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 178 /* 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 @@ -34569,16 +35858,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 143 /* Parameter */: + case 144 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34608,13 +35897,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144 /* Decorator */: + case 145 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34663,12 +35952,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 176 /* NewExpression */) { + if (node.kind === 179 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 149 /* Constructor */ && - declaration.kind !== 153 /* ConstructSignature */ && - declaration.kind !== 158 /* ConstructorType */ && + declaration.kind !== 150 /* Constructor */ && + declaration.kind !== 154 /* ConstructSignature */ && + declaration.kind !== 159 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -34708,9 +35997,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 221 /* FunctionDeclaration */ + ? 224 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 219 /* VariableDeclaration */ + ? 222 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -34807,8 +36096,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 171 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 172 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34866,7 +36155,7 @@ var ts; function createPromiseReturnType(func, promisedType) { var promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } return promiseType; @@ -34878,7 +36167,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200 /* Block */) { + if (func.body.kind !== 203 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -34968,7 +36257,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 217 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -35001,7 +36290,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { + func.kind === 183 /* FunctionExpression */ || func.kind === 184 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -35030,7 +36319,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 (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 203 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -35063,10 +36352,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 183 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -35107,14 +36396,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -35130,7 +36419,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200 /* Block */) { + if (node.body.kind === 203 /* Block */) { checkSourceElement(node.body); } else { @@ -35177,11 +36466,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + (expr.kind === 176 /* PropertyAccessExpression */ || expr.kind === 177 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 149 /* Constructor */)) + if (!(func && func.kind === 150 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -35193,50 +36482,25 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 176 /* PropertyAccessExpression */ || expr.kind === 177 /* ElementAccessExpression */) { + var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 233 /* NamespaceImport */; + return declaration && declaration.kind === 236 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = skipParenthesizedNodes(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { + var node = ts.skipParentheses(expr); + if (node.kind !== 70 /* Identifier */ && node.kind !== 176 /* PropertyAccessExpression */ && node.kind !== 177 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } - // Because we get the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - var links = getNodeLinks(node); - var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - // Only variables (and not functions, classes, namespaces, enum objects, or enum members) - // are considered references when referenced using a simple identifier. - if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { - error(expr, invalidReferenceMessage); - return false; - } - if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { - error(expr, constantVariableMessage); - return false; - } - } - } - else if (node.kind === 174 /* ElementAccessExpression */) { - if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { - error(expr, constantVariableMessage); - return false; - } - } return true; } function checkDeleteExpression(node) { @@ -35254,7 +36518,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 262144 /* AwaitContext */)) { + if (!(node.flags & 524288 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -35290,7 +36554,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -35304,7 +36568,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -35395,29 +36659,29 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var p = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var p = properties_5[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { - if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { - var name_17 = property.name; - if (name_17.kind === 141 /* ComputedPropertyName */) { - checkComputedPropertyName(name_17); + if (property.kind === 256 /* PropertyAssignment */ || property.kind === 257 /* ShorthandPropertyAssignment */) { + var name_21 = property.name; + if (name_21.kind === 142 /* ComputedPropertyName */) { + checkComputedPropertyName(name_21); } - if (isComputedNonLiteralName(name_17)) { + if (isComputedNonLiteralName(name_21)) { return undefined; } - var text = getTextOfPropertyName(name_17); + var text = ts.getTextOfPropertyName(name_21); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 254 /* ShorthandPropertyAssignment */) { + if (property.kind === 257 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -35426,10 +36690,10 @@ var ts; } } else { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); } } - else { + else if (property.kind !== 258 /* SpreadAssignment */) { error(property, ts.Diagnostics.Property_assignment_expected); } } @@ -35447,8 +36711,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 194 /* OmittedExpression */) { - if (element.kind !== 192 /* SpreadElementExpression */) { + if (element.kind !== 197 /* OmittedExpression */) { + if (element.kind !== 195 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -35472,11 +36736,11 @@ var ts; } else { if (elementIndex < elements.length - 1) { - error(element, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { var restExpression = element.expression; - if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 191 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -35489,7 +36753,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 257 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -35505,21 +36769,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 191 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 175 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171 /* ArrayLiteralExpression */) { + if (target.kind === 174 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { + if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; @@ -35538,35 +36802,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 177 /* TaggedTemplateExpression */: - case 190 /* TemplateExpression */: + case 180 /* TaggedTemplateExpression */: + case 193 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 136 /* UndefinedKeyword */: - case 180 /* FunctionExpression */: - case 193 /* ClassExpression */: - case 181 /* ArrowFunction */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 183 /* TypeOfExpression */: - case 197 /* NonNullExpression */: - case 243 /* JsxSelfClosingElement */: - case 242 /* JsxElement */: + case 137 /* UndefinedKeyword */: + case 183 /* FunctionExpression */: + case 196 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 186 /* TypeOfExpression */: + case 200 /* NonNullExpression */: + case 246 /* JsxSelfClosingElement */: + case 245 /* JsxElement */: return true; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -35578,9 +36842,9 @@ var ts; } return false; // Some forms listed here for clarity - case 184 /* VoidExpression */: // Explicit opt-out - case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 187 /* VoidExpression */: // Explicit opt-out + case 181 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 199 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35600,7 +36864,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 175 /* ObjectLiteralExpression */ || left.kind === 174 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -35783,9 +37047,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); - // Use default messages - if (ok) { + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } @@ -35813,7 +37075,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 65536 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 131072 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -35901,8 +37163,8 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = skipParenthesizedNodes(node); - return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; + node = ts.skipParentheses(node); + return node.kind === 181 /* TypeAssertionExpression */ || node.kind === 199 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35934,7 +37196,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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35945,7 +37207,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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35975,7 +37237,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140 /* QualifiedName */) { + if (node.kind === 141 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35987,9 +37249,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); 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); } @@ -36011,66 +37273,66 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return checkCallExpression(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return checkClassExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return checkAssertion(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return checkNonNullAssertion(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return checkDeleteExpression(node); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return checkVoidExpression(node); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return checkAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 192 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 194 /* OmittedExpression */: + case 195 /* SpreadElement */: + return checkSpreadExpression(node, contextualMapper); + case 197 /* OmittedExpression */: return undefinedWideningType; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return checkYieldExpression(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return checkJsxExpression(node); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return checkJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -36098,7 +37360,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -36109,7 +37371,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { + if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -36123,9 +37385,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 148 /* MethodDeclaration */ || - node.kind === 221 /* FunctionDeclaration */ || - node.kind === 180 /* FunctionExpression */; + return node.kind === 149 /* MethodDeclaration */ || + node.kind === 224 /* FunctionDeclaration */ || + node.kind === 183 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -36168,9 +37430,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_18 = _a[_i].name; - if (ts.isBindingPattern(name_18) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { + var name_22 = _a[_i].name; + if (ts.isBindingPattern(name_22) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -36183,16 +37445,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181 /* ArrowFunction */: - case 152 /* CallSignature */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 157 /* FunctionType */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + case 184 /* ArrowFunction */: + case 153 /* CallSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 158 /* FunctionType */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + var parent_11 = node.parent; + if (node === parent_11.type) { + return parent_11; } } } @@ -36202,15 +37464,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_19 = element.name; - if (name_19.kind === 70 /* Identifier */ && - name_19.text === predicateVariableName) { + var name_23 = element.name; + if (name_23.kind === 70 /* Identifier */ && + name_23.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 169 /* ArrayBindingPattern */ || - name_19.kind === 168 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { + else if (name_23.kind === 172 /* ArrayBindingPattern */ || + name_23.kind === 171 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -36218,12 +37480,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || - node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || - node.kind === 153 /* ConstructSignature */) { + else if (node.kind === 158 /* FunctionType */ || node.kind === 224 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || + node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -36235,10 +37497,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 152 /* CallSignature */: + case 153 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -36281,7 +37543,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* Constructor */) { + if (member.kind === 150 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -36295,13 +37557,13 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -36327,7 +37589,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 145 /* PropertySignature */) { + if (member.kind == 146 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -36349,7 +37611,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223 /* InterfaceDeclaration */) { + if (node.kind === 226 /* 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 @@ -36369,7 +37631,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -36377,7 +37639,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -36445,12 +37707,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { + else if (n.kind !== 183 /* FunctionExpression */ && n.kind !== 224 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 /* PropertyDeclaration */ && + return n.kind === 147 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -36480,7 +37742,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -36504,7 +37766,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 150 /* GetAccessor */) { + if (node.kind === 151 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -36514,13 +37776,13 @@ 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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(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 === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; + var otherKind = node.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -36536,11 +37798,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 150 /* GetAccessor */) { + if (node.kind === 151 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 175 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36623,6 +37885,9 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); } @@ -36630,9 +37895,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 !== 223 /* InterfaceDeclaration */ && - n.parent.kind !== 222 /* ClassDeclaration */ && - n.parent.kind !== 193 /* ClassExpression */ && + if (n.parent.kind !== 226 /* InterfaceDeclaration */ && + n.parent.kind !== 225 /* ClassDeclaration */ && + n.parent.kind !== 196 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36720,7 +37985,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && + var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36759,7 +38024,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 226 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36770,7 +38035,7 @@ 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 === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { + if (node.kind === 224 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36892,16 +38157,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -37065,56 +38330,19 @@ var ts; } } /** - * Checks that the return type provided is an instantiation of the global Promise type - * and returns the awaited type of the return type. + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. * - * @param returnType The return type of a FunctionLikeDeclaration - * @param location The node on which to report the error. + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + * + * @param node The signature to check */ - function checkCorrectPromiseType(returnType, location, diagnostic, typeName) { - if (returnType === unknownType) { - // The return type already had some other error, so we ignore and return - // the unknown type. - return unknownType; - } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType === emptyGenericType - || globalPromiseType === getTargetType(returnType)) { - // Either we couldn't resolve the global promise type, which would have already - // reported an error, or we could resolve it and the return type is a valid type - // reference to the global type. In either case, we return the awaited type for - // the return type. - return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - // The promise type was not a valid type reference to the global promise type, so we - // report an error and return the unknown type. - error(location, diagnostic, typeName); - return unknownType; - } - /** - * Checks the return type of an async function to ensure it is a compatible - * Promise implementation. - * @param node The signature to check - * @param returnType The return type for the function - * @remarks - * This checks that an async function has a valid Promise-compatible return type, - * and returns the *awaited type* of the promise. An async function has a valid - * Promise-compatible return type if the resolved value of the return type has a - * construct signature that takes in an `initializer` function that in turn supplies - * a `resolve` function as one of its arguments and results in an object with a - * callable `then` signature. - */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES2015 */) { - var returnType = getTypeFromTypeNode(node.type); - return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - // If we couldn't resolve the global PromiseConstructorLike type we cannot verify - // compatibility with __awaiter. - return unknownType; - } // As part of our emit for an async function, we will need to emit the entity name of // the return type annotation as an expression. To meet the necessary runtime semantics // for __awaiter, we must also check that the type of the declaration (e.g. the static @@ -37139,39 +38367,56 @@ var ts; // then(...): Promise; // } // - // When we get the type of the `Promise` symbol here, we get the type of the static - // side of the `Promise` class, which would be `{ new (...): Promise }`. - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - // If we are compiling with isolatedModules, we may not be able to resolve the - // type as a value. As such, we will just return unknownType; - return unknownType; + var returnType = getTypeFromTypeNode(node.type); + if (languageVersion >= 2 /* ES2015 */) { + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + // The promise type was not a valid type reference to the global promise type, so we + // report an error and return the unknown type. + error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } } - var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - // try to fall back to global promise type. - var typeName = promiseConstructor - ? symbolToString(promiseConstructor) - : typeToString(promiseType); - return checkCorrectPromiseType(promiseType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); - } - // If the Promise constructor, resolved locally, is an alias symbol we should mark it as referenced. - checkReturnTypeAnnotationAsExpression(node); - // Validate the promise constructor type. - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - // Verify there is no local declaration that could collide with the promise constructor. - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, 107455 /* Value */); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseNameOrNamespaceRoot.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; + else { + // Always mark the type node as referenced if it points to a value + markTypeNodeAsReferenced(node.type); + if (returnType === unknownType) { + return unknownType; + } + var promiseConstructorName = ts.getEntityNameFromTypeNode(node.type); + if (promiseConstructorName === undefined) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); + return unknownType; + } + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; + if (promiseConstructorType === unknownType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var collidingSymbol = getSymbol(node.locals, rootName.text, 107455 /* Value */); + if (collidingSymbol) { + error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, rootName.text, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } } // Get and return the awaited type of the return type. - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } /** Check a decorator */ function checkDecorator(node) { @@ -37184,22 +38429,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 143 /* Parameter */: + case 144 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -37207,42 +38452,19 @@ var ts; } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } - /** Checks a type reference node as an expression. */ - function checkTypeNodeAsExpression(node) { - // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we - // serialize the type metadata. - if (node && node.kind === 156 /* TypeReference */) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; - // Resolve type so we know which symbol is referenced - var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - // Resolved symbol is alias - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { - var aliasTarget = resolveAlias(rootSymbol); - // If alias has value symbol - mark alias as referenced - if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } /** - * Checks the type annotation of an accessor declaration or property declaration as - * an expression if it is a type reference to a type with a value declaration. - */ - function checkTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkReturnTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ - function checkParameterTypeAnnotationsAsExpressions(node) { - // ensure all type annotations with a value declaration are checked as an expression - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); + * If a TypeNode can be resolved to a value symbol imported from an external module, it is + * marked as referenced to prevent import elision. + */ + function markTypeNodeAsReferenced(node) { + var typeName = node && ts.getEntityNameFromTypeNode(node); + var rootName = typeName && getFirstIdentifier(typeName); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (rootSymbol + && rootSymbol.flags & 8388608 /* Alias */ + && symbolIsValue(rootSymbol) + && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } /** Check the decorators of a node */ @@ -37261,21 +38483,27 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); + for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + markTypeNodeAsReferenced(parameter.type); + } } break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - checkParameterTypeAnnotationsAsExpressions(node); - checkReturnTypeAnnotationAsExpression(node); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + markTypeNodeAsReferenced(parameter.type); + } + markTypeNodeAsReferenced(node.type); break; - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: - checkTypeAnnotationAsExpression(node); + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: + markTypeNodeAsReferenced(node.type); break; } } @@ -37297,7 +38525,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 === 141 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 142 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -37357,43 +38585,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 256 /* SourceFile */: - case 226 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 229 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -37402,11 +38630,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { + if (node.parent.kind !== 226 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 143 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -37421,16 +38649,16 @@ var ts; } }; for (var key in node.locals) { - _loop_2(key); + _loop_3(key); } } } function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 219 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 208 /* ForInStatement */ || - declaration.parent.parent.kind === 209 /* ForOfStatement */)) { + if (declaration.kind === 222 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 211 /* ForInStatement */ || + declaration.parent.parent.kind === 212 /* ForOfStatement */)) { return; } } @@ -37447,12 +38675,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { + if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 149 /* Constructor */) { + else if (member.kind === 150 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -37500,7 +38728,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 200 /* Block */) { + if (node.kind === 203 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -37523,12 +38751,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 145 /* PropertySignature */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 147 /* MethodSignature */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 146 /* PropertySignature */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 148 /* MethodSignature */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -37537,7 +38765,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -37594,12 +38822,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // 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 === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -37609,12 +38837,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // 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 === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { + if (parent.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -37649,7 +38877,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 === 219 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 222 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37659,24 +38887,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 201 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 223 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 204 /* 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 === 200 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 227 /* ModuleBlock */ || - container.kind === 226 /* ModuleDeclaration */ || - container.kind === 256 /* SourceFile */); + (container.kind === 203 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 230 /* ModuleBlock */ || + container.kind === 229 /* ModuleDeclaration */ || + container.kind === 260 /* 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 // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_20 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); + var name_24 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); } } } @@ -37684,7 +38912,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37695,7 +38923,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 173 /* PropertyAccessExpression */) { + if (n.kind === 176 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -37714,7 +38942,7 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 143 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -37728,7 +38956,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 146 /* PropertyDeclaration */ && + if (current.parent.kind === 147 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37755,24 +38983,25 @@ 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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 170 /* BindingElement */) { + if (node.kind === 173 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_13 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_13); - var name_21 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_13.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); + var parent_12 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_12); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_12.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -37780,14 +39009,14 @@ var ts; 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 === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 144 /* Parameter */ && 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)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 211 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37798,7 +39027,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 211 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37818,10 +39047,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { + if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { + if (node.kind === 222 /* VariableDeclaration */ || node.kind === 173 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37831,8 +39060,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || - (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 222 /* VariableDeclaration */) || + (left.kind === 222 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37862,7 +39091,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 175 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37883,7 +39112,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202 /* EmptyStatement */) { + if (node.thenStatement.kind === 205 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37903,12 +39132,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 223 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37931,14 +39160,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 === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { + if (varExpr.kind === 174 /* ArrayLiteralExpression */ || varExpr.kind === 175 /* 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. @@ -37946,8 +39175,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -37970,7 +39198,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 === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* 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); @@ -37984,7 +39212,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 === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { + if (varExpr.kind === 174 /* ArrayLiteralExpression */ || varExpr.kind === 175 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37992,7 +39220,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } var rightType = checkNonNullExpression(node.expression); @@ -38234,7 +39462,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); + return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -38261,12 +39489,12 @@ var ts; // for generators. return; } - if (func.kind === 151 /* SetAccessor */) { + if (func.kind === 152 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 149 /* Constructor */) { + else if (func.kind === 150 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -38287,7 +39515,7 @@ var ts; } } } - else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 150 /* 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); } @@ -38296,7 +39524,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 262144 /* AwaitContext */) { + if (node.flags & 524288 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -38314,9 +39542,10 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); + 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 === 250 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 253 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -38328,15 +39557,21 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 252 /* CaseClause */) { var caseClause = clause; // 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. var caseType = checkExpression(caseClause.expression); - if (!isTypeEqualityComparableTo(expressionType, caseType)) { + var caseIsLiteral = isLiteralType(caseType); + var comparedExpressionType = expressionType; + if (!caseIsLiteral || !expressionIsLiteral) { + caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType; + comparedExpressionType = getBaseTypeOfLiteralType(expressionType); + } + if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) { // expressionType is not comparable to caseType, try the reversed check and report errors if it fails - checkTypeComparableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + checkTypeComparableTo(caseType, comparedExpressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -38353,7 +39588,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 218 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -38456,7 +39691,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -38514,7 +39749,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { + if (declaration.kind === 225 /* ClassDeclaration */ || declaration.kind === 226 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38579,7 +39814,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 222 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 225 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -38680,7 +39915,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 193 /* ClassExpression */) { + if (derivedClassDecl.kind === 196 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38728,7 +39963,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; + return kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38769,8 +40004,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { - var prop = properties_5[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen[prop.name]; if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; @@ -38800,7 +40035,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 226 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38848,7 +40083,7 @@ var ts; error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { - var text = getTextOfPropertyName(member.name); + var text = ts.getTextOfPropertyName(member.name); if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } @@ -38907,7 +40142,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -38918,7 +40153,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38943,11 +40178,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -38960,7 +40195,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174 /* ElementAccessExpression */) { + if (e.kind === 177 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38978,7 +40213,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 173 /* PropertyAccessExpression */) { + else if (current.kind === 176 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -39050,7 +40285,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 !== 225 /* EnumDeclaration */) { + if (declaration.kind !== 228 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -39073,8 +40308,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 222 /* ClassDeclaration */ || - (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 225 /* ClassDeclaration */ || + (declaration.kind === 224 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -39138,7 +40373,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, 222 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 225 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -39189,26 +40424,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201 /* VariableStatement */: + case 204 /* 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 236 /* ExportAssignment */: - case 237 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 240 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 234 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: - var name_22 = node.name; - if (ts.isBindingPattern(name_22)) { - for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { + case 173 /* BindingElement */: + case 222 /* VariableDeclaration */: + var name_26 = node.name; + if (ts.isBindingPattern(name_26)) { + for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -39216,12 +40451,12 @@ var ts; break; } // fallthrough - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 221 /* FunctionDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 224 /* FunctionDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -39244,12 +40479,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -39262,9 +40497,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 237 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 230 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 240 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -39297,7 +40532,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 239 /* ExportSpecifier */ ? + var message = node.kind === 242 /* 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)); @@ -39325,7 +40560,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 236 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -39382,8 +40617,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 230 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -39397,7 +40632,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 260 /* SourceFile */ || node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 229 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -39423,8 +40658,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 === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 260 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 229 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -39499,7 +40734,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || + return (declaration.kind !== 224 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -39512,118 +40747,121 @@ 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 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return checkTypeParameter(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return checkParameter(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return checkPropertyDeclaration(node); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return checkSignatureDeclaration(node); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return checkMethodDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return checkConstructorDeclaration(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return checkAccessorDeclaration(node); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return checkTypeReferenceNode(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return checkTypePredicate(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return checkTypeQuery(node); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return checkTypeLiteral(node); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return checkArrayType(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return checkTupleType(node); - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: + case 168 /* TypeOperator */: return checkSourceElement(node.type); - case 221 /* FunctionDeclaration */: + case 169 /* IndexedAccessType */: + return checkIndexedAccessType(node); + case 224 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return checkBlock(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return checkVariableStatement(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return checkExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return checkIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return checkDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return checkWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return checkForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return checkForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return checkForOfStatement(node); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return checkReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return checkWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return checkSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return checkLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return checkThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return checkTryStatement(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return checkBindingElement(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return checkClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return checkImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return checkExportDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return checkExportAssignment(node); - case 202 /* EmptyStatement */: + case 205 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39645,17 +40883,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: checkAccessorDeferred(node); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39717,9 +40955,29 @@ var ts; function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { + // Some global diagnostics are deferred until they are needed and + // may not be reported in the firt call to getGlobalDiagnostics. + // We should catch these changes and report them. + var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); + var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + if (currentGlobalDiagnostics !== previousGlobalDiagnostics) { + // If the arrays are not the same reference, new diagnostics were added. + var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics); + return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics); + } + else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) { + // If the arrays are the same reference, but the length has changed, a single + // new diagnostic was added as DiagnosticCollection attempts to reuse the + // same array. + return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics); + } + return semanticDiagnostics; } + // Global diagnostics are always added when a file is not provided to + // getDiagnostics ts.forEach(host.getSourceFiles(), checkSourceFile); return diagnostics.getDiagnostics(); } @@ -39736,7 +40994,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 216 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39759,25 +41017,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; 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 - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* 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. @@ -39786,7 +41044,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39835,28 +41093,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142 /* TypeParameter */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: + case 143 /* TypeParameter */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 140 /* QualifiedName */) { + while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 271 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 176 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 198 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39873,13 +41131,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 233 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 239 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39891,7 +41149,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 176 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39903,13 +41161,13 @@ var ts; default: } } - if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 239 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 176 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 233 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -39919,7 +41177,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 198 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39943,14 +41201,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 173 /* PropertyAccessExpression */) { + else if (entityName.kind === 176 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 140 /* QualifiedName */) { + else if (entityName.kind === 141 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39959,20 +41217,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 271 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 246 /* JsxAttribute */) { + else if (entityName.parent.kind === 249 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 155 /* TypePredicate */) { + if (entityName.parent.kind === 156 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -39990,8 +41248,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 170 /* BindingElement */ && - node.parent.parent.kind === 168 /* ObjectBindingPattern */ && + else if (node.parent.kind === 173 /* BindingElement */ && + node.parent.parent.kind === 171 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -40002,8 +41260,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -40017,12 +41275,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 166 /* ThisType */: + case 167 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -40030,7 +41288,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && + ((node.parent.kind === 234 /* ImportDeclaration */ || node.parent.kind === 240 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -40040,7 +41298,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -40057,7 +41315,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 254 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 257 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -40119,28 +41377,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 175 /* ObjectLiteralExpression */ || expr.kind === 174 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 209 /* ForOfStatement */) { + if (expr.parent.kind === 212 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 188 /* BinaryExpression */) { + if (expr.parent.kind === 191 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 253 /* PropertyAssignment */) { + if (expr.parent.kind === 256 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 174 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -40190,9 +41448,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols_3 = []; - var name_23 = symbol.name; + var name_27 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_23); + var symbol = getPropertyOfType(t, name_27); if (symbol) { symbols_3.push(symbol); } @@ -40200,6 +41458,10 @@ var ts; return symbols_3; } else if (symbol.flags & 67108864 /* Transient */) { + if (symbol.leftSpread) { + var links = symbol; + return [links.leftSpread, links.rightSpread]; + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -40272,7 +41534,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 256 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 260 /* SourceFile */) { var symbolFile = parentSymbol.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. @@ -40329,7 +41591,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 203 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -40375,16 +41637,16 @@ var ts; return true; } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -40394,7 +41656,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 256 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 260 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -40460,7 +41722,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255 /* EnumMember */) { + if (node.kind === 259 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -40561,9 +41823,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_14 = reference.parent; - if (ts.isDeclaration(parent_14) && reference === parent_14.name) { - location = getDeclarationContainer(parent_14); + var parent_13 = reference.parent; + if (ts.isDeclaration(parent_13) && reference === parent_13.name) { + location = getDeclarationContainer(parent_13); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -40583,7 +41845,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 262144 /* FreshLiteral */); + return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */); } return false; } @@ -40637,7 +41899,8 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - writeLiteralConstValue: writeLiteralConstValue + writeLiteralConstValue: writeLiteralConstValue, + getJsxFactoryEntity: function () { return _jsxFactoryEntity; } }; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -40648,7 +41911,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 176 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40674,6 +41937,10 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + // found at least one entry that does not originate from type reference directive + return undefined; + } } } return typeReferenceDirectives; @@ -40687,15 +41954,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_14 = getParentOfSymbol(current); + if (parent_14) { + current = parent_14; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 260 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -40715,7 +41982,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 260 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -40748,7 +42015,7 @@ var ts; } } if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 31744 /* EmitHelperFlags */; + var fileRequestedExternalEmitHelpers = file.flags & 64512 /* EmitHelperFlags */; if (fileRequestedExternalEmitHelpers) { requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; if (firstFileRequestingExternalHelpers === undefined) { @@ -40827,9 +42094,13 @@ var ts; if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } - if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { + if (requestedExternalEmitHelpers & 16384 /* HasSpreadAttribute */ && + (languageVersion < 5 /* ESNext */ || compilerOptions.jsx === 2 /* React */)) { verifyHelperSymbol(exports, "__assign", 107455 /* Value */); } + if (languageVersion < 5 /* ESNext */ && requestedExternalEmitHelpers & 32768 /* HasRestAttribute */) { + verifyHelperSymbol(exports, "__rest", 107455 /* Value */); + } if (requestedExternalEmitHelpers & 2048 /* HasDecorators */) { verifyHelperSymbol(exports, "__decorate", 107455 /* Value */); if (compilerOptions.emitDecoratorMetadata) { @@ -40878,14 +42149,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 149 /* 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 === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */) { + else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* 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); @@ -40902,17 +42173,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 !== 129 /* ReadonlyKeyword */) { - if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { + if (modifier.kind !== 130 /* ReadonlyKeyword */) { + if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + if (node.kind !== 228 /* EnumDeclaration */ && node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -40938,7 +42209,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 === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -40961,10 +42232,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 === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40973,11 +42244,11 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { + else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* 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); } @@ -40997,10 +42268,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -41012,13 +42283,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 230 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -41028,14 +42299,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 222 /* ClassDeclaration */) { - if (node.kind !== 148 /* MethodDeclaration */ && - node.kind !== 146 /* PropertyDeclaration */ && - node.kind !== 150 /* GetAccessor */ && - node.kind !== 151 /* SetAccessor */) { + if (node.kind !== 225 /* ClassDeclaration */) { + if (node.kind !== 149 /* MethodDeclaration */ && + node.kind !== 147 /* PropertyDeclaration */ && + node.kind !== 151 /* GetAccessor */ && + node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 222 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 225 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -41054,7 +42325,7 @@ var ts; else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -41062,7 +42333,7 @@ var ts; break; } } - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -41077,13 +42348,13 @@ var ts; } return; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 234 /* ImportDeclaration */ || node.kind === 233 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 144 /* 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 === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 144 /* 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 */) { @@ -41103,37 +42374,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 154 /* IndexSignature */: - case 226 /* ModuleDeclaration */: - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: - case 236 /* ExportAssignment */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 143 /* Parameter */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 155 /* IndexSignature */: + case 229 /* ModuleDeclaration */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 144 /* Parameter */: return false; default: - if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return false; } switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 223 /* InterfaceDeclaration */: - case 201 /* VariableStatement */: - case 224 /* TypeAliasDeclaration */: + case 226 /* InterfaceDeclaration */: + case 204 /* VariableStatement */: + case 227 /* TypeAliasDeclaration */: return true; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -41146,10 +42417,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148 /* MethodDeclaration */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -41212,7 +42483,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 184 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -41247,7 +42518,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 !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { + if (parameter.type.kind !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -41275,7 +42546,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 194 /* OmittedExpression */) { + if (arg.kind === 197 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -41348,19 +42619,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 141 /* ComputedPropertyName */) { + if (node.kind !== 142 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 191 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 148 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 224 /* FunctionDeclaration */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -41385,12 +42656,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_24 = prop.name; - if (name_24.kind === 141 /* ComputedPropertyName */) { - // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_24); + if (prop.kind === 258 /* SpreadAssignment */) { + continue; } - if (prop.kind === 254 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + var name_28 = prop.name; + if (name_28.kind === 142 /* ComputedPropertyName */) { + // If the name is not a ComputedPropertyName, the grammar checking will skip it + checkGrammarComputedPropertyName(name_28); + } + if (prop.kind === 257 /* 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.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -41399,7 +42673,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -41413,27 +42687,27 @@ var ts; // 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 = void 0; - if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { + if (prop.kind === 256 /* PropertyAssignment */ || prop.kind === 257 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_24.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_24); + if (name_28.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } - else if (prop.kind === 148 /* MethodDeclaration */) { + else if (prop.kind === 149 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 150 /* GetAccessor */) { + else if (prop.kind === 151 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 151 /* SetAccessor */) { + else if (prop.kind === 152 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -41443,18 +42717,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -41463,19 +42737,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 247 /* JsxSpreadAttribute */) { + if (attr.kind === 250 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_25 = jsxAttr.name; - if (!seen[name_25.text]) { - seen[name_25.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 248 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 251 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -41484,7 +42758,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 223 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -41499,20 +42773,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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 === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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 === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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); @@ -41536,11 +42810,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 151 /* SetAccessor */) { + else if (kind === 152 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -41563,10 +42837,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. 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 === 150 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -41581,7 +42855,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.parent.kind === 175 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -41602,10 +42876,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 226 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 160 /* TypeLiteral */) { + else if (node.parent.kind === 161 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41616,11 +42890,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 210 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 213 /* 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); @@ -41628,8 +42902,8 @@ var ts; return false; } break; - case 214 /* SwitchStatement */: - if (node.kind === 211 /* BreakStatement */ && !node.label) { + case 217 /* SwitchStatement */: + if (node.kind === 214 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41644,13 +42918,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 /* BreakStatement */ + var message = node.kind === 214 /* 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 === 211 /* BreakStatement */ + var message = node.kind === 214 /* 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); @@ -41660,24 +42934,24 @@ var ts; if (node.dotDotDotToken) { var elements = node.parent.elements; if (node !== ts.lastOrUndefined(elements)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { + if (node.name.kind === 172 /* ArrayBindingPattern */ || node.name.kind === 171 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { - // Error on equals token which immediate precedes the initializer + // Error on equals token which immediately precedes the initializer return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 189 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { + if (node.parent.parent.kind !== 211 /* ForInStatement */ && node.parent.parent.kind !== 212 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41742,15 +43016,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 213 /* WithStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: return false; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41805,7 +43079,7 @@ var ts; return true; } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 226 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41813,7 +43087,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 160 /* TypeLiteral */) { + else if (node.parent.kind === 161 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41838,13 +43112,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 223 /* InterfaceDeclaration */ || - node.kind === 224 /* TypeAliasDeclaration */ || - node.kind === 231 /* ImportDeclaration */ || - node.kind === 230 /* ImportEqualsDeclaration */ || - node.kind === 237 /* ExportDeclaration */ || - node.kind === 236 /* ExportAssignment */ || - node.kind === 229 /* NamespaceExportDeclaration */ || + if (node.kind === 226 /* InterfaceDeclaration */ || + node.kind === 227 /* TypeAliasDeclaration */ || + node.kind === 234 /* ImportDeclaration */ || + node.kind === 233 /* ImportEqualsDeclaration */ || + node.kind === 240 /* ExportDeclaration */ || + node.kind === 239 /* ExportAssignment */ || + node.kind === 232 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41853,7 +43127,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 === 201 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 204 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41879,7 +43153,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 === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 203 /* Block */ || node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41939,49 +43213,49 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[140 /* QualifiedName */] = [ + _a[141 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[144 /* Decorator */] = [ + _a[145 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[178 /* TypeAssertionExpression */] = [ + _a[181 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196 /* AsExpression */] = [ + _a[199 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197 /* NonNullExpression */] = [ + _a[200 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225 /* EnumDeclaration */] = [ + _a[228 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226 /* ModuleDeclaration */] = [ + _a[229 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227 /* ModuleBlock */] = [ + _a[230 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[230 /* ImportEqualsDeclaration */] = [ + _a[233 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241 /* ExternalModuleReference */] = [ + _a[244 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255 /* EnumMember */] = [ + _a[259 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -42004,47 +43278,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { + if ((kind >= 156 /* TypePredicate */ && kind <= 170 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: - case 287 /* NotEmittedStatement */: + case 202 /* SemicolonClassElement */: + case 205 /* EmptyStatement */: + case 197 /* OmittedExpression */: + case 221 /* DebuggerStatement */: + case 291 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 143 /* Parameter */: + case 144 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 144 /* Decorator */: + case 145 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42053,12 +43327,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* Constructor */: + case 150 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42066,7 +43340,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42074,45 +43348,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 170 /* BindingElement */: + case 173 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175 /* CallExpression */: + case 178 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* NewExpression */: + case 179 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -42120,119 +43394,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 179 /* ParenthesizedExpression */: - case 182 /* DeleteExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 185 /* AwaitExpression */: - case 191 /* YieldExpression */: - case 192 /* SpreadElementExpression */: - case 197 /* NonNullExpression */: + case 182 /* ParenthesizedExpression */: + case 185 /* DeleteExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 188 /* AwaitExpression */: + case 194 /* YieldExpression */: + case 195 /* SpreadElement */: + case 200 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 200 /* Block */: + case 203 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 204 /* IfStatement */: + case 207 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205 /* DoStatement */: + case 208 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206 /* WhileStatement */: - case 213 /* WithStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForStatement */: + case 210 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 219 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217 /* TryStatement */: + case 220 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42241,7 +43515,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42249,94 +43523,97 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 232 /* ImportClause */: + case 235 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: result = reduceNode(node.tagName, f, result); break; - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: result = reduceNode(node.expression, f, result); break; - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: result = reduceNode(node.expression, f, result); break; // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: result = reduceNode(node.expression, f, result); // fall-through - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: result = ts.reduceLeft(node.statements, f, result); break; - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: result = ts.reduceLeft(node.types, f, result); break; - case 252 /* CatchClause */: + case 255 /* CatchClause */: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; + case 258 /* SpreadAssignment */: + result = reduceNode(node.expression, f, result); + break; // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: result = ts.reduceLeft(node.statements, f, result); break; - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, f, result); break; default: @@ -42361,6 +43638,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -42409,6 +43687,7 @@ var ts; // Visit each original node. for (var i = 0; i < count; i++) { var node = nodes[i + start]; + aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -42447,192 +43726,194 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { + if ((kind >= 156 /* TypePredicate */ && kind <= 170 /* LiteralType */)) { return node; } switch (node.kind) { - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: + case 202 /* SemicolonClassElement */: + case 205 /* EmptyStatement */: + case 197 /* OmittedExpression */: + case 221 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 143 /* Parameter */: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 144 /* Parameter */: + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* Constructor */: + case 150 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 171 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169 /* ArrayBindingPattern */: + case 172 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 200 /* Block */: + case 203 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 234 /* NamedImports */: + case 237 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 238 /* NamedExports */: + case 241 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 258 /* SpreadAssignment */: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -42781,7 +44062,7 @@ var ts; * @param recordTempVariable A callback used to record new temporary variables. * @param visitor An optional visitor to use to visit expressions. */ - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor) { + function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { var right = node.right; if (ts.isDestructuringAssignment(right)) { @@ -42812,7 +44093,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); if (needsValue) { expressions.push(value); } @@ -42832,6 +44113,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; /** @@ -42841,9 +44125,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor, transformRest) { var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42858,6 +44142,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; /** @@ -42867,10 +44154,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { var declarations = []; var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42902,6 +44189,9 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; /** @@ -42909,36 +44199,40 @@ var ts; * * @param node The VariableDeclaration to flatten. * @param recordTempVariable A callback used to record new temporary variables. - * @param nameSubstitution An optional callback used to substitute binding names. + * @param createAssignmentCallback An optional callback used to create assignment expressions + * for non-temporary variables. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { var pendingAssignments = []; - flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, /*transformRest*/ false, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; function emitAssignment(name, value, location, original) { - var left = nameSubstitution && nameSubstitution(name) || name; - emitPendingAssignment(left, value, location, original); + var expression = createAssignmentCallback + ? createAssignmentCallback(name.kind === 70 /* Identifier */ ? name : emitTempVariableAssignment(name, location), value, location) + : ts.createAssignment(name, value, location); + emitPendingAssignment(expression, original); } function emitTempVariableAssignment(value, location) { var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(name, value, location, /*original*/ undefined); + emitPendingAssignment(ts.createAssignment(name, value, location), /*original*/ undefined); return name; } - function emitPendingAssignment(name, value, location, original) { - var expression = ts.createAssignment(name, value, location); + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectLiteral(elements), value, location, original); + } + function emitPendingAssignment(expression, original) { expression.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); pendingAssignments.push(expression); - return expression; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42970,17 +44264,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 175 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171 /* ArrayLiteralExpression */) { + else if (target.kind === 174 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { - var name_26 = ts.getMutableClone(target); - ts.setSourceMapRange(name_26, target); - ts.setCommentRange(name_26, target); - emitAssignment(name_26, value, location, /*original*/ undefined); + var name_30 = ts.getMutableClone(target); + ts.setSourceMapRange(name_30, target); + ts.setCommentRange(name_30, target); + emitAssignment(name_30, value, location, /*original*/ undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -42991,30 +44285,95 @@ var ts; // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); } - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; - if (p.kind === 253 /* PropertyAssignment */ || p.kind === 254 /* ShorthandPropertyAssignment */) { - var propName = p.name; - var target_1 = p.kind === 254 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - // Assignment for target = value.propName should highligh whole property, hence use p as source map node - emitDestructuringAssignment(target_1, createDestructuringPropertyAccess(value, propName), p); + var bindingElements = []; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 256 /* PropertyAssignment */ || p.kind === 257 /* ShorthandPropertyAssignment */) { + if (!transformRest || + p.transformFlags & 8388608 /* ContainsSpreadExpression */ || + (p.kind === 256 /* PropertyAssignment */ && p.initializer.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 257 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for bindingTarget = value.propName should highlight whole property, hence use p as source map node + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && p.kind === 258 /* SpreadAssignment */) { + ts.Debug.assert(p.expression.kind === 70 /* Identifier */); + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.expression; + var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); + emitDestructuringAssignment(propName, restCall, p); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; } } function emitArrayLiteralAssignment(target, value, location) { + if (transformRest) { + emitESNextArrayLiteralAssignment(target, value, location); + } + else { + emitES2015ArrayLiteralAssignment(target, value, location); + } + } + function emitESNextArrayLiteralAssignment(target, value, location) { var elements = target.elements; var numElements = elements.length; if (numElements !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed-in source map node since thats the one needing this temp assignment + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); + } + var expressions = []; + var spreadContainingExpressions = []; + for (var i = 0; i < numElements; i++) { + var e = elements[i]; + if (e.kind === 197 /* OmittedExpression */) { + continue; + } + if (e.transformFlags & 8388608 /* ContainsSpreadExpression */ && i < numElements - 1) { + var tmp = ts.createTempVariable(recordTempVariable); + spreadContainingExpressions.push([e, tmp]); + expressions.push(tmp); + } + else { + expressions.push(e); + } + } + emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); + for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { + var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; + emitDestructuringAssignment(e, tmp, e); + } + } + function emitES2015ArrayLiteralAssignment(target, value, location) { + var elements = target.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + // When doing so we want to highlight the passed-in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 194 /* OmittedExpression */) { + if (e.kind !== 197 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 192 /* SpreadElementExpression */) { + if (e.kind !== 195 /* SpreadElement */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -43023,10 +44382,30 @@ var ts; } } } + /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement + * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ + function createRestCall(value, elements, getPropertyName, location) { + var propertyNames = []; + for (var i = 0; i < elements.length - 1; i++) { + if (ts.isOmittedExpression(elements[i])) { + continue; + } + var str = ts.createSynthesizedNode(9 /* StringLiteral */); + str.pos = location.pos; + str.end = location.end; + str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); + propertyNames.push(str); + } + var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.createIdentifier("__rest"), undefined, args); + } function emitBindingElement(target, value) { // Any temporary assignments needed to emit target = value should point to target var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (initializer) { + if (transformRest) { + value = value || initializer; + } + else if (initializer) { // Combine value and initializer value = value ? createDefaultValueCheck(value, initializer, target) : initializer; } @@ -43035,9 +44414,11 @@ var ts; value = ts.createVoidZero(); } var name = target.name; - if (ts.isBindingPattern(name)) { - var elements = name.elements; - var numElements = elements.length; + if (!ts.isBindingPattern(name)) { + emitAssignment(name, value, target, target); + } + else { + var numElements = name.elements.length; if (numElements !== 1) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -43045,29 +44426,98 @@ var ts; // so in that case, we'll intentionally create that temporary. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0, target, emitTempVariableAssignment); } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - else if (name.kind === 168 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } - else { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + if (name.kind === 172 /* ArrayBindingPattern */) { + emitArrayBindingElement(name, value); + } + else { + emitObjectBindingElement(target, value); } } + } + function emitArrayBindingElement(name, value) { + if (transformRest) { + emitESNextArrayBindingElement(name, value); + } else { - emitAssignment(name, value, target, target); + emitES2015ArrayBindingElement(name, value); + } + } + function emitES2015ArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, ts.createElementAccess(value, i)); + } + else if (i === numElements - 1) { + emitBindingElement(element, ts.createArraySlice(value, i)); + } + } + } + function emitESNextArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + var spreadContainingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (element.transformFlags & 8388608 /* ContainsSpreadExpression */ && i < numElements - 1) { + spreadContainingElements.push(element); + bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + } + else { + bindingElements.push(element); + } + } + emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); + for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { + var element = spreadContainingElements_1[_i]; + emitBindingElement(element, ts.getGeneratedNameForNode(element)); + } + } + function emitObjectBindingElement(target, value) { + var name = target.name; + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (i === numElements - 1 && element.dotDotDotToken) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); + emitBindingElement(element, restCall); + } + else if (transformRest && !(element.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + // do not emit until we have a complete bundle of ES2015 syntax + bindingElements.push(element); + } + else { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; } } function createDefaultValueCheck(value, defaultValue, location) { @@ -43158,15 +44608,15 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(174 /* ElementAccessExpression */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(177 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -43227,7 +44677,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return visitSourceFile(node); } else if (node.transformFlags & 1 /* TypeScript */) { @@ -43255,13 +44705,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return visitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -43281,11 +44731,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 237 /* ExportDeclaration */ || - node.kind === 231 /* ImportDeclaration */ || - node.kind === 232 /* ImportClause */ || - (node.kind === 230 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 241 /* ExternalModuleReference */)) { + if (node.kind === 240 /* ExportDeclaration */ || + node.kind === 234 /* ImportDeclaration */ || + node.kind === 235 /* ImportClause */ || + (node.kind === 233 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 244 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -43315,25 +44765,34 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 149 /* Constructor */: + case 150 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 146 /* PropertyDeclaration */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: + case 147 /* PropertyDeclaration */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); return undefined; } } + function modifierVisitor(node) { + if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + return undefined; + } + else if (currentNamespace && node.kind === 83 /* ExportKeyword */) { + return undefined; + } + return node; + } /** * Branching visitor, visits a TypeScript syntax node. * @@ -43356,45 +44815,47 @@ var ts; case 116 /* AbstractKeyword */: case 75 /* ConstKeyword */: case 123 /* DeclareKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 160 /* TypeLiteral */: - case 155 /* TypePredicate */: - case 142 /* TypeParameter */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 161 /* TypeLiteral */: + case 156 /* TypePredicate */: + case 143 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 134 /* SymbolKeyword */: - case 158 /* ConstructorType */: - case 157 /* FunctionType */: - case 159 /* TypeQuery */: - case 156 /* TypeReference */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 135 /* SymbolKeyword */: + case 159 /* ConstructorType */: + case 158 /* FunctionType */: + case 160 /* TypeQuery */: + case 157 /* TypeReference */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* LiteralType */: // TypeScript type nodes are elided. - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: // TypeScript index signatures are elided. - case 144 /* Decorator */: + case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 149 /* Constructor */: + case 150 /* Constructor */: return visitConstructor(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43405,7 +44866,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43416,35 +44877,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 143 /* Parameter */: + case 144 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -43454,33 +44915,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -43495,15 +44956,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 227 /* ModuleBlock */: - case 200 /* Block */: + case 260 /* SourceFile */: + case 231 /* CaseBlock */: + case 230 /* ModuleBlock */: + case 203 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222 /* ClassDeclaration */: - case 221 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: + case 224 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -43514,13 +44975,17 @@ var ts; function visitSourceFile(node) { currentSourceFile = node; // ensure "use strict" is emitted in all scenarios in alwaysStrict mode - if (compilerOptions.alwaysStrict) { + // There is no need to emit "use strict" in the following cases: + // 1. The file is an external module and target is es2015 or higher + // or 2. The file is an external module and module-kind is es6 or es2015 as such value is not allowed when targeting es5 or lower + if (compilerOptions.alwaysStrict && + !(ts.isExternalModule(node) && (compilerOptions.target >= 2 /* ES2015 */ || compilerOptions.module === ts.ModuleKind.ES2015))) { node = ts.ensureUseStrict(node); } // If the source file requires any helpers and is an external module, and // the importHelpers compiler option is enabled, emit a synthesized import // statement for the helpers library. - if (node.flags & 31744 /* EmitHelperFlags */ + if (node.flags & 64512 /* EmitHelperFlags */ && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { startLexicalEnvironment(); @@ -43533,10 +44998,10 @@ var ts; externalHelpersModuleImport.parent = node; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); - currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; + currentExternalHelpersModuleName = externalHelpersModuleName; ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - currentSourceFileExternalHelpersModuleName = undefined; + currentExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } @@ -43580,7 +45045,6 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); - var classAlias; // emit name if // - node has a name // - node has static initializers @@ -43589,38 +45053,22 @@ var ts; if (!name && staticProperties.length > 0) { name = ts.getGeneratedNameForNode(node); } - var statements = []; - if (!isDecoratedClass) { - // ${modifiers} class ${name} ${heritageClauses} { - // ${members} - // } - var classDeclaration = ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), - /*location*/ node); - ts.setOriginalNode(classDeclaration, node); - // To better align with the old emitter, we should not emit a trailing source map - // entry if the class has static properties. - if (staticProperties.length > 0) { - ts.setEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | ts.getEmitFlags(classDeclaration)); - } - statements.push(classDeclaration); - } - else { - classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); - } + var classStatement = isDecoratedClass + ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) + : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + var statements = [classStatement]; // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, ts.getLocalName(node)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node, classAlias); + addConstructorDecorationStatement(statements, node); // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. @@ -43629,26 +45077,54 @@ var ts; } else if (isDecoratedClass) { if (isDefaultExternalModuleExport(node)) { - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getLocalName(node))); + statements.push(ts.createExportDefault(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } else if (isNamedExternalModuleExport(node)) { - statements.push(createExternalModuleExport(name)); + statements.push(ts.createExternalModuleExport(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } - return statements; + if (statements.length > 1) { + // Add a DeclarationMarker as a marker for the end of the declaration + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432 /* HasEndOfDeclarationMarker */); + } + return ts.singleOrMany(statements); + } + /** + * Transforms a non-decorated class declaration and appends the resulting statements. + * + * @param node A ClassDeclaration node. + * @param name The name of the class. + * @param hasExtendsClause A value indicating whether the class has an extends clause. + * @param hasStaticProperties A value indicating whether the class has static properties. + */ + function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { + // ${modifiers} class ${name} ${heritageClauses} { + // ${members} + // } + var classDeclaration = ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var emitFlags = ts.getEmitFlags(node); + // To better align with the old emitter, we should not emit a trailing source map + // entry if the class has static properties. + if (hasStaticProperties) { + emitFlags |= 1024 /* NoTrailingSourceMap */; + } + ts.setOriginalNode(classDeclaration, node); + ts.setEmitFlags(classDeclaration, emitFlags); + return classDeclaration; } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. * + * @param statements A statement list to which to add the declaration. * @param node A ClassDeclaration node. * @param name The name of the class. - * @param hasExtendsClause A value indicating whether + * @param hasExtendsClause A value indicating whether the class has an extends clause. */ - function addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause) { + function createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -43683,20 +45159,20 @@ var ts; // --------------------------------------------------------------------- // TypeScript | Javascript // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = C_1 = class C { // class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); + // | var C_1; // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = class C { // export class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); // | export { C }; + // | var C_1; // --------------------------------------------------------------------- // // If a class declaration is the default export of a module, we instead emit @@ -43725,59 +45201,31 @@ var ts; // --------------------------------------------------------------------- // TypeScript | Javascript // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = class C { // export default class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); // | export default C; + // | var C_1; // --------------------------------------------------------------------- // var location = ts.moveRangePastDecorators(node); + var classAlias = getClassAliasIfNeeded(node); + var declName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { // ${members} // } - var classExpression = ts.setOriginalNode(ts.createClassExpression( - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), - /*location*/ location), node); - if (!name) { - name = ts.getGeneratedNameForNode(node); - } - // Record an alias to avoid class double-binding. - var classAlias; - if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { - enableSubstitutionForClassAliases(); - classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - } - var declaredName = getDeclarationName(node, /*allowComments*/ true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = transformClassMembers(node, hasExtendsClause); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + ts.setOriginalNode(classExpression, node); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var transformedClassExpression = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(classAlias || declaredName, - /*type*/ undefined, classExpression) - ]), - /*location*/ location); - ts.setCommentRange(transformedClassExpression, node); - statements.push(ts.setOriginalNode( - /*node*/ transformedClassExpression, - /*original*/ node)); - if (classAlias) { - // We emit the class alias as a `let` declaration here so that it has the same - // TDZ as the class. - // let ${declaredName} = ${decoratedClassAlias} - statements.push(ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(declaredName, - /*type*/ undefined, classAlias) - ]), - /*location*/ location), - /*original*/ node)); - } - return classAlias; + var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setOriginalNode(statement, node); + ts.setCommentRange(statement, node); + return statement; } /** * Transforms a class expression with TypeScript syntax into compatible ES6. @@ -43840,7 +45288,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 4194304 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43960,7 +45408,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -44033,7 +45481,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 146 /* PropertyDeclaration */ + return member.kind === 147 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -44168,12 +45616,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -44325,11 +45773,11 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 146 /* PropertyDeclaration */ + ? member.kind === 147 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); ts.setEmitFlags(helper, 49152 /* NoComments */); return helper; } @@ -44338,8 +45786,8 @@ var ts; * * @param node The class node. */ - function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { - var expression = generateConstructorDecorationExpression(node, decoratedClassAlias); + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); if (expression) { statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); } @@ -44349,33 +45797,19 @@ var ts; * * @param node The class node. */ - function generateConstructorDecorationExpression(node, decoratedClassAlias) { + function generateConstructorDecorationExpression(node) { var allDecorators = getAllDecoratorsOfConstructor(node); var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators); if (!decoratorExpressions) { return undefined; } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = C_1 = __decorate([dec], C); - // - if (decoratedClassAlias) { - var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); - var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152 /* NoComments */); - return result; - } - else { - var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152 /* NoComments */); - return result; - } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 49152 /* NoComments */); + ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); + return expression; } /** * Transforms a decorator into an expression. @@ -44397,7 +45831,7 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, + var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, /*location*/ decorator.expression); ts.setEmitFlags(helper, 49152 /* NoComments */); expressions.push(helper); @@ -44422,13 +45856,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -44436,16 +45870,16 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeParameterTypesOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); } } } @@ -44458,10 +45892,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 146 /* PropertyDeclaration */; + return kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 147 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -44471,7 +45905,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 148 /* MethodDeclaration */; + return node.kind === 149 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -44482,11 +45916,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 222 /* ClassDeclaration */ - || kind === 193 /* ClassExpression */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */; + return kind === 225 /* ClassDeclaration */ + || kind === 196 /* ClassExpression */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -44495,15 +45929,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: - case 150 /* GetAccessor */: + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: + case 151 /* GetAccessor */: return serializeTypeNode(node.type); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 148 /* MethodDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -44516,10 +45950,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 161 /* ArrayType */) { + if (node && node.kind === 162 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 156 /* TypeReference */) { + else if (node && node.kind === 157 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44595,20 +46029,20 @@ var ts; switch (node.kind) { case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return ts.createIdentifier("Function"); - case 161 /* ArrayType */: - case 162 /* TupleType */: + case 162 /* ArrayType */: + case 163 /* TupleType */: return ts.createIdentifier("Array"); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: return ts.createIdentifier("String"); - case 167 /* LiteralType */: + case 170 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -44622,16 +46056,16 @@ var ts; break; } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return serializeTypeReferenceNode(node); - case 164 /* IntersectionType */: - case 163 /* UnionType */: + case 165 /* IntersectionType */: + case 164 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44660,10 +46094,12 @@ var ts; } } // Fallthrough - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: + case 160 /* TypeQuery */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 161 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44720,15 +46156,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_27 = ts.getMutableClone(node); - name_27.flags &= ~8 /* Synthesized */; - name_27.original = undefined; - name_27.parent = currentScope; + var name_31 = ts.getMutableClone(node); + name_31.flags &= ~8 /* Synthesized */; + name_31.original = undefined; + name_31.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); } - return name_27; - case 140 /* QualifiedName */: + return name_31; + case 141 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44861,7 +46297,7 @@ var ts; return undefined; } var method = ts.createMethod( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44895,14 +46331,14 @@ var ts; return undefined; } var accessor = ts.createGetAccessor( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } /** @@ -44919,13 +46355,13 @@ var ts; return undefined; } var accessor = ts.createSetAccessor( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } /** @@ -44943,7 +46379,7 @@ var ts; return ts.createNotEmittedStatement(node); } var func = ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44967,7 +46403,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44980,7 +46416,7 @@ var ts; * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -45040,7 +46476,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameterDeclaration( + var parameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, @@ -45077,7 +46513,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), @@ -45143,21 +46579,6 @@ var ts; || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } - function shouldEmitVarForEnumDeclaration(node) { - return isFirstEmittedDeclarationInScope(node) - && (!ts.hasModifier(node, 1 /* Export */) - || isES6ExportedDeclaration(node)); - } - /* - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForEnumExportedFromNamespace(statements, node) { - var statement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, getExportName(node))]); - ts.setSourceMapRange(statement, node); - statements.push(statement); - } /** * Visits an enum declaration. * @@ -45176,9 +46597,7 @@ var ts; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForEnumDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384 /* NoLeadingComments */; @@ -45189,7 +46608,18 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1 /* Export */) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) + : ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // x || (x = {}) + // exports.x || (exports.x = {}) + var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); + if (hasNamespaceQualifiedExportName(node)) { + // `localName` is the expression used within this node's containing scope for any local references. + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // x = (exports.x || (exports.x = {})) + moduleArg = ts.createAssignment(localName, moduleArg); + } // (function (x) { // x[x["y"] = 0] = "y"; // ... @@ -45198,16 +46628,16 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), + /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); - if (isNamespaceExport(node)) { - addVarForEnumExportedFromNamespace(statements, node); - } + // Add a DeclarationMarker for the enum to preserve trailing comments and mark + // the end of the declaration. + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } /** @@ -45269,9 +46699,15 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isES6ExportedDeclaration(node) { - return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES2015; + /** + * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` + * or `exports.x`). + */ + function hasNamespaceQualifiedExportName(node) { + return isNamespaceExport(node) + || (isExternalModuleExport(node) + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.System); } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -45297,55 +46733,64 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_28 = node.symbol && node.symbol.name; - if (name_28) { - return currentScopeFirstDeclarationsOfName[name_28] === node; + var name_32 = node.symbol && node.symbol.name; + if (name_32) { + return currentScopeFirstDeclarationsOfName[name_32] === node; } } return false; } - function shouldEmitVarForModuleDeclaration(node) { - return isFirstEmittedDeclarationInScope(node); - } /** * Adds a leading VariableStatement for a enum or module declaration. */ function addVarForEnumOrModuleDeclaration(statements, node) { // Emit a variable statement for the module. - var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) - ? ts.visitNodes(node.modifiers, visitor, ts.isModifier) - : undefined, [ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) + var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), [ + ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) ]); - ts.setOriginalNode(statement, /*original*/ node); - // Adjust the source map emit to match the old emitter. - if (node.kind === 225 /* EnumDeclaration */) { - ts.setSourceMapRange(statement.declarationList, node); + ts.setOriginalNode(statement, node); + recordEmittedDeclarationInScope(node); + if (isFirstEmittedDeclarationInScope(node)) { + // Adjust the source map emit to match the old emitter. + if (node.kind === 228 /* EnumDeclaration */) { + ts.setSourceMapRange(statement.declarationList, node); + } + else { + ts.setSourceMapRange(statement, node); + } + // Trailing comments for module declaration should be emitted after the function closure + // instead of the variable statement: + // + // /** Module comment*/ + // module m1 { + // function foo4Export() { + // } + // } // trailing comment module + // + // Should emit: + // + // /** Module comment*/ + // var m1; + // (function (m1) { + // function foo4Export() { + // } + // })(m1 || (m1 = {})); // trailing comment module + // + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 /* NoTrailingComments */ | 33554432 /* HasEndOfDeclarationMarker */); + statements.push(statement); + return true; } else { - ts.setSourceMapRange(statement, node); + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrap the leading variable declaration in a `MergeDeclarationMarker`. + var mergeMarker = ts.createMergeDeclarationMarker(statement); + ts.setEmitFlags(mergeMarker, 49152 /* NoComments */ | 33554432 /* HasEndOfDeclarationMarker */); + statements.push(mergeMarker); + return false; } - // Trailing comments for module declaration should be emitted after the function closure - // instead of the variable statement: - // - // /** Module comment*/ - // module m1 { - // function foo4Export() { - // } - // } // trailing comment module - // - // Should emit: - // - // /** Module comment*/ - // var m1; - // (function (m1) { - // function foo4Export() { - // } - // })(m1 || (m1 = {})); // trailing comment module - // - ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768 /* NoTrailingComments */); - statements.push(statement); } /** * Visits a module declaration node. @@ -45367,9 +46812,7 @@ var ts; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForModuleDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384 /* NoLeadingComments */; @@ -45380,13 +46823,15 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1 /* Export */) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) + : ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) // exports.x || (exports.x = {}) var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); - if (ts.hasModifier(node, 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if (hasNamespaceQualifiedExportName(node)) { // `localName` is the expression used within this node's containing scope for any local references. - var localName = getLocalName(node); + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x = (exports.x || (exports.x = {})) moduleArg = ts.createAssignment(localName, moduleArg); } @@ -45397,13 +46842,16 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); + // Add a DeclarationMarker for the namespace to preserve trailing comments and mark + // the end of the declaration. + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } /** @@ -45423,7 +46871,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227 /* ModuleBlock */) { + if (body.kind === 230 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -45469,13 +46917,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 (body.kind !== 227 /* ModuleBlock */) { + if (body.kind !== 230 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 229 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -45516,7 +46964,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 233 /* NamespaceImport */) { + if (node.kind === 236 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -45623,9 +47071,9 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ - ts.createVariableDeclaration(node.name, - /*type*/ undefined, moduleReference) + return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + ts.setOriginalNode(ts.createVariableDeclaration(node.name, + /*type*/ undefined, moduleReference), node) ]), node), node); } else { @@ -45674,38 +47122,20 @@ var ts; return ts.createStatement(expression, /*location*/ undefined); } function addExportMemberAssignment(statements, node) { - var expression = ts.createAssignment(getExportName(node), getLocalName(node, /*noSourceMaps*/ true)); + var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(getNamespaceMemberName(exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); } - function createExternalModuleExport(exportName) { - return ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createNamedExports([ - ts.createExportSpecifier(exportName) - ])); - } - function getNamespaceMemberName(name, allowComments, allowSourceMaps) { - var qualifiedName = ts.createPropertyAccess(currentNamespaceContainerName, ts.getSynthesizedClone(name), /*location*/ name); - var emitFlags; - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (emitFlags) { - ts.setEmitFlags(qualifiedName, emitFlags); - } - return qualifiedName; + function createNamespaceExportExpression(exportName, exportValue, location) { + return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { - return getNamespaceMemberName(name, /*allowComments*/ false, /*allowSourceMaps*/ true); + return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); } /** * Gets the declaration name used inside of a namespace or enum. @@ -45723,67 +47153,25 @@ var ts; return ts.getGeneratedNameForNode(node); } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. - * @param allowComments A value indicating whether comments may be emitted for the name. + * Gets a local alias for a class declaration if it is a decorated class with an internal + * reference to the static side of the class. This is necessary to avoid issues with + * double-binding semantics for the class name. */ - function getLocalName(node, noSourceMaps, allowComments) { - return getDeclarationName(node, allowComments, !noSourceMaps, 262144 /* LocalName */); - } - /** - * Gets the export name for a declaration for use in expressions. - * - * An export name will *always* be prefixed with an module or namespace export modifier - * like "exports." if one is required. - * - * @param node The declaration. - * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. - * @param allowComments A value indicating whether comments may be emitted for the name. - */ - function getExportName(node, noSourceMaps, allowComments) { - if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); - } - return getDeclarationName(node, allowComments, !noSourceMaps, 131072 /* ExportName */); - } - /** - * Gets the name for a declaration for use in declarations. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - * @param emitFlags Additional NodeEmitFlags to specify for the name. - */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name) { - var name_29 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_29, emitFlags); - } - return name_29; - } - else { - return ts.getGeneratedNameForNode(node); + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { + enableSubstitutionForClassAliases(); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; } } function getClassPrototype(node) { - return ts.createPropertyAccess(getDeclarationName(node), "prototype"); + return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { return ts.hasModifier(member, 32 /* Static */) - ? getDeclarationName(node) + ? ts.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { @@ -45808,20 +47196,21 @@ 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(70 /* Identifier */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableSubstitution(257 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(226 /* ModuleDeclaration */); + context.enableEmitNotification(229 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 229 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 228 /* EnumDeclaration */; } /** * Hook for node emit. * + * @param emitContext A context hint for the emitter. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ @@ -45839,9 +47228,8 @@ var ts; /** * Hooks node substitutions. * + * @param emitContext A context hint for the emitter. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -45855,16 +47243,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_30 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_30); + var name_33 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_33); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_30, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_33, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_30, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_33, exportedName, /*location*/ node); } } return node; @@ -45873,9 +47261,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -45909,13 +47297,13 @@ var ts; } function trySubstituteNamespaceExportedName(node) { // If this is explicitly a local name, do not substitute. - if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { // 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) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); + if (container && container.kind !== 260 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 229 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 228 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45957,1909 +47345,6 @@ var ts; } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES2015Module(context) { - var compilerOptions = context.getCompilerOptions(); - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - } - return node; - } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; - } - } - ts.transformES2015Module = transformES2015Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(188 /* BinaryExpression */); - context.enableSubstitution(186 /* PrefixUnaryExpression */); - context.enableSubstitution(187 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; - } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 237 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. - */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 231 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 230 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 237 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); - } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 231 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 201 /* VariableStatement */: - return visitVariableStatement(node); - case 221 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 207 /* ForStatement */: - return visitForStatement(node); - case 208 /* ForInStatement */: - return visitForInStatement(node); - case 209 /* ForOfStatement */: - return visitForOfStatement(node); - case 205 /* DoStatement */: - return visitDoStatement(node); - case 206 /* WhileStatement */: - return visitWhileStatement(node); - case 215 /* LabeledStatement */: - return visitLabeledStatement(node); - case 213 /* WithStatement */: - return visitWithStatement(node); - case 214 /* SwitchStatement */: - return visitSwitchStatement(node); - case 228 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 217 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 200 /* Block */: - return visitBlock(node); - case 203 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - // Elide `export=` as it is illegal in a SystemJS module. - return undefined; - } - return createExportStatement(ts.createLiteral("default"), node.expression); - } - /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. - * - * @param node The variable statement to visit. - */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - /** - * Transforms a VariableDeclaration into one or more assignment expressions. - * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. - */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); - } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); - } - } - /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. - */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - // Keep async modifier for ES2017 transformer - var isAsync = ts.hasModifier(node, 256 /* Async */); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 225 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. - * - * @param node The class declaration to visit. - */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; - } - /** - * Visits the body of a ForStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. - * - * @param node The decalaration list to transform. - */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); - } - /** - * Visits the body of a ForInStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a ForOfStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a DoStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WhileStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a LabeledStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WithStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - /** - * Visits the body of a CaseBlock to hoist declarations. - * - * @param node The node to visit. - */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - /** - * Visits the body of a CaseClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - /** - * Visits the body of a DefaultClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a TryStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a CatchClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - /** - * Visits the body of a Block to hoist declarations. - * - * @param node The block to visit. - */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - /** - * Substitute the expression, if necessary. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 188 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for identifiers exported at the top level of a module. - */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 70 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 172 /* ObjectLiteralExpression */: - case 171 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 70 /* Identifier */: - return isExportedBinding(node); - case 172 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 171 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 57 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 172 /* ObjectLiteralExpression */ - || kind === 171 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 187 /* PostfixUnaryExpression */ || - (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 186 /* PrefixUnaryExpression */) { - return call; - } - else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(188 /* BinaryExpression */); - context.enableSubstitution(186 /* PrefixUnaryExpression */); - context.enableSubstitution(187 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } - } - } - /** - * Visits a node at the top level of the source file. - * - * @param node The node. - */ - function visitor(node) { - switch (node.kind) { - case 231 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - case 201 /* VariableStatement */: - return visitVariableStatement(node); - case 221 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 203 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The ImportDeclaration node. - */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - // Elide as `export=` is handled in addExportEqualsIfNeeded - return undefined; - } - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); - } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 226 /* ModuleDeclaration */ || - originalKind === 225 /* EnumDeclaration */ || - originalKind === 222 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); - } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - // Keep async modifier for ES2017 transformer - var isAsync = ts.hasModifier(node, 256 /* Async */); - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 222 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 225 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 188 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 187 /* PostfixUnaryExpression */: - case 186 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 187 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); /// /// /*@internal*/ @@ -47897,11 +47382,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -47912,11 +47397,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitJsxExpression(node); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -47953,7 +47438,7 @@ var ts; objectProperties = ts.singleOrUndefined(segments) || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -47975,7 +47460,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 248 /* JsxExpression */) { + else if (node.kind === 251 /* JsxExpression */) { return visitJsxExpression(node); } else { @@ -48057,16 +47542,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242 /* JsxElement */) { + if (node.kind === 245 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_34 = node.tagName; + if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { + return ts.createLiteral(name_34.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_34); } } } @@ -48351,6 +47836,232 @@ var ts; /// /*@internal*/ var ts; +(function (ts) { + function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + currentSourceFile = node; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16 /* ESNext */) { + return visitorWorker(node); + } + else if (node.transformFlags & 32 /* ContainsESNext */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 175 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 191 /* BinaryExpression */: + return visitBinaryExpression(node); + case 222 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 212 /* ForOfStatement */: + return visitForOfStatement(node); + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: + return node; + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 183 /* FunctionExpression */: + return visitFunctionExpression(node); + case 184 /* ArrowFunction */: + return visitArrowFunction(node); + case 144 /* Parameter */: + return visitParameter(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 258 /* SpreadAssignment */) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 256 /* PropertyAssignment */) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + // spread elements emit like so: + // non-spread elements are chunked together into object literals, and then all are passed to __assign: + // { a, ...o, b } => __assign({a}, o, {b}); + // If the first element is a spread element, then the first argument to __assign is {}: + // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 175 /* ObjectLiteralExpression */) { + objects.unshift(ts.createObjectLiteral()); + } + return ts.createCall(ts.createIdentifier("__assign"), undefined, objects); + } + /** + * Visits a BinaryExpression that contains a destructuring assignment. + * + * @param node A BinaryExpression node. + */ + function visitBinaryExpression(node) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48 /* AssertESNext */) { + return ts.flattenDestructuringAssignment(context, node, /*needsDestructuringValue*/ true, hoistVariableDeclaration, visitor, /*transformRest*/ true); + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclaration node with a binding pattern. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern with a rest somewhere in it. + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48 /* AssertESNext */) { + var result = ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, /*recordTempVariable*/ undefined, /*transformRest*/ true); + return result; + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ForOfStatement and converts it into a ES2015-compatible ForOfStatement. + * + * @param node A ForOfStatement. + */ + function visitForOfStatement(node) { + // The following ESNext code: + // + // for (let { x, y, ...rest } of expr) { } + // + // should be emitted as + // + // for (var _a of expr) { + // let { x, y } = _a, rest = __rest(_a, ["x", "y"]); + // } + // + // where _a is a temp emitted to capture the RHS. + // When the left hand side is an expression instead of a let declaration, + // the `let` before the `{ x, y }` is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + // for ( of ) + // where is [let] variabledeclarationlist | expression + var initializer = node.initializer; + if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { + return ts.visitEachChild(node, visitor, context); + } + return ts.convertForOf(node, undefined, visitor, ts.noop, context, /*transformRest*/ true); + } + function isRestBindingPattern(initializer) { + if (ts.isVariableDeclarationList(initializer)) { + var declaration = ts.firstOrUndefined(initializer.declarations); + return declaration && declaration.name && + declaration.name.kind === 171 /* ObjectBindingPattern */ && + !!(declaration.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 175 /* ObjectLiteralExpression */ && + initializer.transformFlags & 8388608 /* ContainsSpreadExpression */; + } + function visitParameter(node) { + if (isObjectRestParameter(node)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, + /*type*/ undefined, node.initializer, + /*location*/ node), + /*original*/ node); + } + else { + return node; + } + } + function isObjectRestParameter(node) { + return node.name && + node.name.kind === 171 /* ObjectBindingPattern */ && + !!(node.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + function visitFunctionDeclaration(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, body, + /*location*/ node), + /*original*/ node); + } + function visitArrowFunction(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + var func = ts.setOriginalNode(ts.createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, body, + /*location*/ node), + /*original*/ node); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; + } + function visitFunctionExpression(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, body, + /*location*/ node), + /*original*/ node); + } + } + ts.transformESNext = transformESNext; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; (function (ts) { function transformES2017(context) { var ES2017SubstitutionFlags; @@ -48395,10 +48106,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16 /* ES2017 */) { + if (node.transformFlags & 64 /* ES2017 */) { return visitorWorker(node); } - else if (node.transformFlags & 32 /* ContainsES2017 */) { + else if (node.transformFlags & 128 /* ContainsES2017 */) { return ts.visitEachChild(node, visitor, context); } return node; @@ -48408,19 +48119,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -48541,9 +48252,10 @@ var ts; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformAsyncFunctionBody(node) { - var nodeType = node.original ? node.original.type : node.type; + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var isArrowFunction = node.kind === 184 /* 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 @@ -48593,12 +48305,14 @@ var ts; } } function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; + if (type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } } } return undefined; @@ -48608,24 +48322,24 @@ 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(175 /* CallExpression */); - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(174 /* ElementAccessExpression */); + context.enableSubstitution(178 /* CallExpression */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(177 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(222 /* ClassDeclaration */); - context.enableEmitNotification(148 /* MethodDeclaration */); - context.enableEmitNotification(150 /* GetAccessor */); - context.enableEmitNotification(151 /* SetAccessor */); - context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(225 /* ClassDeclaration */); + context.enableEmitNotification(149 /* MethodDeclaration */); + context.enableEmitNotification(151 /* GetAccessor */); + context.enableEmitNotification(152 /* SetAccessor */); + context.enableEmitNotification(150 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -48669,11 +48383,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 /* ClassDeclaration */ - || kind === 149 /* Constructor */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */; + return kind === 225 /* ClassDeclaration */ + || kind === 150 /* Constructor */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Hook for node emit. @@ -48739,10 +48453,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 64 /* ES2016 */) { + if (node.transformFlags & 256 /* ES2016 */) { return visitorWorker(node); } - else if (node.transformFlags & 128 /* ContainsES2016 */) { + else if (node.transformFlags & 512 /* ContainsES2016 */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48751,7 +48465,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48927,11 +48641,11 @@ var ts; return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 212 /* ReturnStatement */ && !node.expression; + return isInConstructorWithCapturedSuper && node.kind === 215 /* ReturnStatement */ && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 256 /* ES2015 */) !== 0 || - node.kind === 215 /* LabeledStatement */ || + return (node.transformFlags & 1024 /* ES2015 */) !== 0 || + node.kind === 218 /* LabeledStatement */ || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { @@ -48941,7 +48655,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 2048 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { // we want to dive in this branch either if node has children with ES2015 specific syntax // or we are inside constructor that captures result of the super call so all returns without expression should be // rewritten. Note: we skip expressions since returns should never appear there @@ -48963,15 +48677,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitSwitchStatement(node); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: return visitBreakOrContinueStatement(node); case 98 /* ThisKeyword */: return visitThisKeyword(node); @@ -48983,77 +48697,77 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83 /* ExportKeyword */: - return node; - case 222 /* ClassDeclaration */: + case 114 /* StaticKeyword */: + return undefined; // elide static keyword + case 225 /* ClassDeclaration */: return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return visitClassExpression(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return visitParameter(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return visitArrowFunction(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitLabeledStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return visitForOfStatement(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return visitExpressionStatement(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return visitCatchClause(node); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return visitTemplateExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitYieldExpression(node); case 96 /* SuperKeyword */: return visitSuperKeyword(); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: // `yield` will be handled by a generators transform. return ts.visitEachChild(node, visitor, context); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return visitSourceFileNode(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -49068,7 +48782,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181 /* ArrowFunction */) { + if (currentNode.kind !== 184 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; @@ -49079,14 +48793,14 @@ var ts; // variable statements, variable declarations, binding elements, and binding // patterns. switch (currentNode.kind) { - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: enclosingVariableStatement = currentNode; break; - case 220 /* VariableDeclarationList */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 223 /* VariableDeclarationList */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: break; default: enclosingVariableStatement = undefined; @@ -49115,7 +48829,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + if (enclosingFunction && enclosingFunction.kind === 184 /* ArrowFunction */) { // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -49140,13 +48854,13 @@ 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 === 211 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 214 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 214 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49157,7 +48871,7 @@ var ts; } } else { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 214 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49201,33 +48915,29 @@ var ts; // } // return C; // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); + var variable = ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); + ts.setOriginalNode(variable, node); + var statements = []; + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); ts.setOriginalNode(statement, node); ts.startOnNewLine(statement); + statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; + if (ts.hasModifier(node, 1 /* Export */)) { + var exportStatement = ts.hasModifier(node, 512 /* Default */) + ? ts.createExportDefault(ts.getLocalName(node)) + : ts.createExternalModuleExport(ts.getLocalName(node)); + ts.setOriginalNode(exportStatement, statement); + statements.push(exportStatement); } - return statement; - } - function isExportModifier(node) { - return node.kind === 83 /* ExportKeyword */; + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 33554432 /* HasEndOfDeclarationMarker */) === 0) { + // Add a DeclarationMarker as a marker for the end of the declaration + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statement, emitFlags | 33554432 /* HasEndOfDeclarationMarker */); + } + return ts.singleOrMany(statements); } /** * Visits a ClassExpression and transforms it into an expression. @@ -49282,7 +48992,7 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "_super")] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier @@ -49317,7 +49027,7 @@ var ts; addClassMembers(statements, node); // Create a synthetic text range for the return statement. var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); - var localName = getLocalName(node); + var localName = ts.getLocalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); @@ -49341,7 +49051,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), /*location*/ extendsClauseElement)); } } @@ -49358,7 +49068,7 @@ var ts; var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), + /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), /*location*/ constructor || node); @@ -49409,8 +49119,8 @@ var ts; statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); } if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, /*convertObjectRest*/ false); + ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -49449,17 +49159,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 212 /* ReturnStatement */) { + if (statement.kind === 215 /* ReturnStatement */) { return true; } - else if (statement.kind === 204 /* IfStatement */) { + else if (statement.kind === 207 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200 /* Block */) { + else if (statement.kind === 203 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49476,7 +49186,7 @@ var ts; // If this isn't a derived class, just capture 'this' for arrow functions if necessary. if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0 /* NoReplacement */; } @@ -49491,7 +49201,7 @@ var ts; // for something like property initializers. // Create a captured '_this' variable and assume it will subsequently be used. if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1 /* ReplaceSuperCapture */; } @@ -49517,7 +49227,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -49528,7 +49238,7 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; @@ -49554,14 +49264,24 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined, /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, node.name, + /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined, /*location*/ node), /*original*/ node); @@ -49570,158 +49290,6 @@ var ts; return node; } } - /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. - * - * @param node A function-like node. - */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; - } - /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); - } - } - } - /** - * Adds statements to the body of a function-like node for parameters with binding patterns - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } - } - /** - * Adds statements to the body of a function-like node for parameters with initializers. - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); - } - /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. - * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; - } - /** - * Adds statements to the body of a function-like node if it contains a rest parameter. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - /** - * Adds a statement to capture the `this` of a function declaration if it is needed. - * - * @param statements The statements for the new function body. - * @param node A node. - */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -49733,20 +49301,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 149 /* Constructor */: + case 150 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -49852,7 +49420,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + if (node.transformFlags & 262144 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); @@ -49876,7 +49444,7 @@ var ts; return ts.setOriginalNode(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), + /*type*/ undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), /*location*/ node), /*original*/ node); } @@ -49889,91 +49457,17 @@ var ts; */ function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181 /* ArrowFunction */) { + if (node.kind !== 184 /* ArrowFunction */) { enclosingNonArrowFunction = node; } var expression = ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*type*/ undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), /*original*/ node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } - /** - * Transforms the body of a function-like node. - * - * @param node A function-like node. - */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 181 /* 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 - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -49982,9 +49476,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -50000,10 +49494,10 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (needsDestructuringValue) { switch (node.expression.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); } @@ -50032,7 +49526,7 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*createAssignmentCallback*/ undefined, visitor); } else { assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); @@ -50065,7 +49559,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + if (node.transformFlags & 67108864 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify @@ -50131,8 +49625,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && enclosingBlockScopeContainer.kind !== 211 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 212 /* ForOfStatement */ && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -50213,118 +49707,7 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, /*transformRest*/ false); } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50340,8 +49723,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 141 /* ComputedPropertyName */) { + if (property.transformFlags & 134217728 /* ContainsYield */ + || property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -50407,11 +49790,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 223 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50460,7 +49843,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + && (node.statement.transformFlags & 134217728 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256 /* CapturesThis */; @@ -50469,14 +49852,14 @@ var ts; loopBodyFlags |= 2097152 /* AsyncFunctionBody */; } var convertedLoopVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ + /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) - ])); + ]), 16777216 /* NoHoisting */)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; // propagate state from the inner loop to the outer loop if necessary @@ -50558,7 +49941,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 /* LabeledStatement */ + statements.push(currentParent.kind === 218 /* LabeledStatement */ ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -50664,7 +50047,7 @@ var ts; } } else { - loopParameters.push(ts.createParameter(name)); + loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { var outParamName = ts.createUniqueName("out_" + name.text); loopOutParameters.push({ originalName: name, outParamName: outParamName }); @@ -50686,20 +50069,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -50828,7 +50211,7 @@ var ts; ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); } var resultingCall; - if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + if (node.transformFlags & 8388608 /* ContainsSpreadExpression */) { // [source] // f(...a, b) // x.m(...a, b) @@ -50874,7 +50257,7 @@ var ts; */ function visitNewExpression(node) { // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 0); + ts.Debug.assert((node.transformFlags & 8388608 /* ContainsSpreadExpression */) !== 0); // [source] // new C(...a) // @@ -50885,7 +50268,7 @@ var ts; /*typeArguments*/ undefined, []); } /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * Transforms an array of Expression nodes that contains a SpreadExpression. * * @param elements The array of Expression nodes. * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. @@ -50900,36 +50283,36 @@ var ts; // Map spans of spread expressions into their expressions and spans of other // expressions into an array literal. var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 174 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } // Rewrite using the pattern .concat(, , ...) return ts.createArrayConcat(segments.shift(), segments); } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function partitionSpread(node) { + return ts.isSpreadExpression(node) + ? visitSpanOfSpreads + : visitSpanOfNonSpreads; } - function visitSpanOfSpreadElements(chunk) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function visitSpanOfSpreads(chunk) { + return ts.map(chunk, visitExpressionOfSpread); } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), /*location*/ undefined, multiLine); } /** - * Transforms the expression of a SpreadElementExpression node. + * Transforms the expression of a SpreadExpression node. * - * @param node A SpreadElementExpression node. + * @param node A SpreadExpression node. */ - function visitExpressionOfSpreadElement(node) { + function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } /** @@ -51086,7 +50469,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 175 /* CallExpression */ + && currentParent.kind !== 178 /* CallExpression */ ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -51095,7 +50478,7 @@ var ts; var statements = []; startLexicalEnvironment(); ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); + ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); ts.addRange(statements, endLexicalEnvironment()); var clone = ts.getMutableClone(node); @@ -51134,21 +50517,20 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(149 /* Constructor */); - context.enableEmitNotification(148 /* MethodDeclaration */); - context.enableEmitNotification(150 /* GetAccessor */); - context.enableEmitNotification(151 /* SetAccessor */); - context.enableEmitNotification(181 /* ArrowFunction */); - context.enableEmitNotification(180 /* FunctionExpression */); - context.enableEmitNotification(221 /* FunctionDeclaration */); + context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(149 /* MethodDeclaration */); + context.enableEmitNotification(151 /* GetAccessor */); + context.enableEmitNotification(152 /* SetAccessor */); + context.enableEmitNotification(184 /* ArrowFunction */); + context.enableEmitNotification(183 /* FunctionExpression */); + context.enableEmitNotification(224 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * + * @param emitContext The context for the emitter. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -51183,10 +50565,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170 /* BindingElement */: - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 222 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51233,44 +50615,8 @@ var ts; } return node; } - /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); - } - /** - * Gets the name of a declaration, without source map or comments. - * - * @param node The declaration. - * @param allowComments Allow comments for the name. - */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_38 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_38, emitFlags); - } - return name_38; - } - return ts.getGeneratedNameForNode(node); - } function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); + var expression = ts.getLocalName(node); return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { @@ -51282,11 +50628,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 206 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 178 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -51294,7 +50640,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 195 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -51536,7 +50882,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 4096 /* ContainsGenerator */) { + if (node.transformFlags & 8192 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -51556,10 +50902,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 2048 /* Generator */) { + else if (transformFlags & 4096 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 4096 /* ContainsGenerator */) { + else if (transformFlags & 8192 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -51573,13 +50919,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitWhileStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -51592,30 +50938,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitForInStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return visitBreakStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return visitContinueStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 16777216 /* ContainsYield */) { + if (node.transformFlags & 134217728 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (8192 /* ContainsGenerator */ | 268435456 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -51630,21 +50976,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return visitConditionalExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitYieldExpression(node); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -51657,9 +51003,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -51820,7 +51166,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 16777216 /* ContainsYield */) { + if (node.transformFlags & 134217728 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -51888,7 +51234,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -51900,7 +51246,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -52269,35 +51615,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200 /* Block */: + case 203 /* Block */: return transformAndEmitBlock(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return transformAndEmitIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return transformAndEmitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return transformAndEmitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return transformAndEmitWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52717,7 +52063,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 250 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 253 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -52730,7 +52076,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 252 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -52861,7 +52207,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 134217728 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -52891,9 +52237,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_8 = ts.getMutableClone(name_39); + var name_35 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_35) { + var clone_8 = ts.getMutableClone(name_35); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -53295,7 +52641,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -53304,7 +52650,7 @@ var ts; } return expression; } - return ts.createNode(194 /* OmittedExpression */); + return ts.createOmittedExpression(); } /** * Creates a numeric literal for the provided instruction. @@ -53489,7 +52835,7 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(state)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) @@ -53879,8 +53225,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(253 /* PropertyAssignment */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(256 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53945,9 +53291,2452 @@ var ts; } ts.transformES5 = transformES5; })(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 233 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(191 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(189 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(190 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(260 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. + var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. + var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + var currentSourceFile; // The current file. + var moduleInfo; // ExternalModuleInfo for the current file. + var exportFunction; // The export function for the current file. + var contextObject; // The context object for the current file. + var hoistedStatements; + var enclosingBlockScopedContainer; + var noSubstitution; // Set of nodes for which substitution rules should be ignored. + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + enclosingBlockScopedContainer = node; + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + // Collect information about the external module and dependency groups. + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + contextObject = ts.createUniqueName("context"); + // Add the body of the module. + var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, exportFunction), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, contextObject) + ], + /*type*/ undefined, createSystemModuleBody(node, dependencyGroups)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction])) + ], node.statements)); + ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1 /* EmitEmitHelpers */); + if (noSubstitution) { + noSubstitutionMap[id] = noSubstitution; + noSubstitution = undefined; + } + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + contextObject = undefined; + hoistedStatements = undefined; + enclosingBlockScopedContainer = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Collects the dependency groups for this files imports. + * + * @param externalImports The imports for the file. + */ + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + /** + * Adds the statements for the module body function for the source file. + * + * @param node The source file for the module. + * @param dependencyGroups The grouped dependencies of the module. + */ + function createSystemModuleBody(node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // var file_1, y; + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + var statements = []; + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + // Emit early exports for function declarations. + ts.addRange(statements, hoistedStatements); + // We emit hoisted variables early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + ts.addRange(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(body, 1 /* EmitEmitHelpers */); + return body; + } + /** + * Adds an exportStar function to a statement list if it is needed for the file. + * + * @param statements A statement list. + */ + function addExportStarIfNeeded(statements) { + if (!moduleInfo.hasExportStarsToExportValues) { + return; + } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { + var externalImport = _a[_i]; + if (externalImport.kind === 240 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + var exportStarFunction_1 = createExportStarFunction(/*localNames*/ undefined); + statements.push(exportStarFunction_1); + return exportStarFunction_1.name; + } + } + var exportedNames = []; + if (moduleInfo.exportedNames) { + for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) { + var exportedLocalName = _c[_b]; + if (exportedLocalName.text === "default") { + continue; + } + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + } + } + for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { + var externalImport = _e[_d]; + if (externalImport.kind !== 240 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { + var element = _g[_f]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); + statements.push(exportStarFunction); + return exportStarFunction.name; + } + /** + * Creates an exportStar function for the file, with an optional set of excluded local + * names. + * + * @param localNames An optional reference to an object containing a set of excluded local + * names. + */ + function createExportStarFunction(localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + } + return ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunction, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true)); + } + /** + * Creates an array setter callbacks for each dependency group. + * + * @param exportStarFunction A reference to an exportStarFunction for the file. + * @param dependencyGroups An array of grouped dependencies. + */ + function createSettersArray(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 234 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 233 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 240 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunction, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + } + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + } + // + // Top-level Source Element Visitors + // + /** + * Visit source elements at the top-level of a module. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + switch (node.kind) { + case 234 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 233 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 240 /* ExportDeclaration */: + // ExportDeclarations are elided as they are handled via + // `appendExportsOfDeclaration`. + return undefined; + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return nestedElementVisitor(node); + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + if (node.importClause) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; + } + var expression = ts.visitNode(node.expression, destructuringVisitor, ts.isExpression); + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, /*allowComments*/ true); + } + else { + return createExportStatement(ts.createIdentifier("default"), expression, /*allowComments*/ true); + } + } + /** + * Visits a FunctionDeclaration, hoisting it to the outer module body function. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), + /*type*/ undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + } + else { + hoistedStatements = ts.append(hoistedStatements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); + } + return undefined; + } + /** + * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + // Hoist the name of the class declaration to the outer module body function. + var name = ts.getLocalName(node); + hoistVariableDeclaration(name); + // Rewrite the class declaration into an assignment of a class expression. + statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), + /*location*/ node)), + /*location*/ node)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + if (!shouldHoistVariableDeclarationList(node.declarationList)) { + return ts.visitNode(node, destructuringVisitor, ts.isStatement); + } + var expressions; + var isExportedDeclaration = ts.hasModifier(node, 1 /* Export */); + var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } + var statements; + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + } + if (isMarkedDeclaration) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + } + else { + statements = appendExportsOfVariableStatement(statements, node, /*exportSelf*/ false); + } + return ts.singleOrMany(statements); + } + /** + * Hoists the declared names of a VariableDeclaration or BindingElement. + * + * @param node The declaration to hoist. + */ + function hoistBindingElement(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + hoistBindingElement(element); + } + } + } + else { + hoistVariableDeclaration(ts.getSynthesizedClone(node.name)); + } + } + /** + * Determines whether a VariableDeclarationList should be hoisted. + * + * @param node The node to test. + */ + function shouldHoistVariableDeclarationList(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + return (ts.getEmitFlags(node) & 16777216 /* NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 260 /* SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + } + /** + * Transform an initialized variable declaration into an expression. + * + * @param node The node to transform. + * @param isExportedDeclaration A value indicating whether the variable is exported. + */ + function transformInitializedVariable(node, isExportedDeclaration) { + var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; + return ts.isBindingPattern(node.name) + ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); + } + /** + * Creates an assignment expression for an exported variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + */ + function createExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, /*isExportedDeclaration*/ true); + } + /** + * Creates an assignment expression for a non-exported variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + */ + function createNonExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, /*isExportedDeclaration*/ false); + } + /** + * Creates an assignment expression for a variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + * @param isExportedDeclaration A value indicating whether the variable is exported. + */ + function createVariableAssignment(name, value, location, isExportedDeclaration) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + return isExportedDeclaration + ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) + : preventSubstitution(ts.createAssignment(name, value, location)); + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // 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 === 204 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + } + return node; + } + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the export of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + * @param exportSelf A value indicating whether to also export each VariableDeclaration of + * `nodes` declaration list. + */ + function appendExportsOfVariableStatement(statements, node, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.initializer || exportSelf) { + statements = appendExportsOfBindingElement(statements, decl, exportSelf); + } + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + * @param exportSelf A value indicating whether to also export the declaration itself. + */ + function appendExportsOfBindingElement(statements, decl, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element, exportSelf); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + var excludeName = void 0; + if (exportSelf) { + statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl)); + excludeName = decl.name.text; + } + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var excludeName; + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createLiteral("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl)); + excludeName = exportName.text; + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + * @param excludeName An optional name to exclude from exports. + */ + function appendExportsOfDeclaration(statements, decl, excludeName) { + if (moduleInfo.exportEquals) { + return statements; + } + var name = ts.getDeclarationName(decl); + var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + if (exportSpecifier.name.text !== excludeName) { + statements = appendExportStatement(statements, exportSpecifier.name, name); + } + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, allowComments)); + return statements; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value)); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + */ + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; + return ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + } + // + // Top-Level or Nested Source Element Visitors + // + /** + * Visit nested elements at the top-level of a module. + * + * @param node The node to visit. + */ + function nestedElementVisitor(node) { + switch (node.kind) { + case 204 /* VariableStatement */: + return visitVariableStatement(node); + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 225 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 210 /* ForStatement */: + return visitForStatement(node); + case 211 /* ForInStatement */: + return visitForInStatement(node); + case 212 /* ForOfStatement */: + return visitForOfStatement(node); + case 208 /* DoStatement */: + return visitDoStatement(node); + case 209 /* WhileStatement */: + return visitWhileStatement(node); + case 218 /* LabeledStatement */: + return visitLabeledStatement(node); + case 216 /* WithStatement */: + return visitWithStatement(node); + case 217 /* SwitchStatement */: + return visitSwitchStatement(node); + case 231 /* CaseBlock */: + return visitCaseBlock(node); + case 252 /* CaseClause */: + return visitCaseClause(node); + case 253 /* DefaultClause */: + return visitDefaultClause(node); + case 220 /* TryStatement */: + return visitTryStatement(node); + case 255 /* CatchClause */: + return visitCatchClause(node); + case 203 /* Block */: + return visitBlock(node); + case 293 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 294 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + return destructuringVisitor(node); + } + } + /** + * Visits the body of a ForStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a ForInStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForInStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a ForOfStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForOfStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Determines whether to hoist the initializer of a ForStatement, ForInStatement, or + * ForOfStatement. + * + * @param node The node to test. + */ + function shouldHoistForInitializer(node) { + return ts.isVariableDeclarationList(node) + && shouldHoistVariableDeclarationList(node); + } + /** + * Visits the initializer of a ForStatement, ForInStatement, or ForOfStatement + * + * @param node The node to visit. + */ + function visitForInitializer(node) { + if (shouldHoistForInitializer(node)) { + var expressions = void 0; + for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + expressions = ts.append(expressions, transformInitializedVariable(variable, /*isExportedDeclaration*/ false)); + } + return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression(); + } + else { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + } + /** + * Visits the body of a DoStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitDoStatement(node) { + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + } + /** + * Visits the body of a WhileStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitWhileStatement(node) { + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a LabeledStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitLabeledStatement(node) { + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a WithStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitWithStatement(node) { + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a SwitchStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitSwitchStatement(node) { + return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + } + /** + * Visits the body of a CaseBlock to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a CaseClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseClause(node) { + return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + } + /** + * Visits the body of a DefaultClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitDefaultClause(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + /** + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitTryStatement(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitCatchClause(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a Block to hoist declarations. + * + * @param node The node to visit. + */ + function visitBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.visitEachChild(node, nestedElementVisitor, context); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + // + // Destructuring Assignment Visitors + // + /** + * Visit nodes to flatten destructuring assignments to exported symbols. + * + * @param node The node to visit. + */ + function destructuringVisitor(node) { + if (node.transformFlags & 16384 /* DestructuringAssignment */ + && node.kind === 191 /* BinaryExpression */) { + return visitDestructuringAssignment(node); + } + else if (node.transformFlags & 32768 /* ContainsDestructuringAssignment */) { + return ts.visitEachChild(node, destructuringVisitor, context); + } + else { + return node; + } + } + /** + * Visits a DestructuringAssignment to flatten destructuring to exported symbols. + * + * @param node The node to visit. + */ + function visitDestructuringAssignment(node) { + if (hasExportedReferenceInDestructuringTarget(node.left)) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration, destructuringVisitor); + } + return ts.visitEachChild(node, destructuringVisitor, context); + } + /** + * Determines whether the target of a destructuring assigment refers to an exported symbol. + * + * @param node The destructuring target. + */ + function hasExportedReferenceInDestructuringTarget(node) { + if (ts.isAssignmentExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.left); + } + else if (ts.isSpreadExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.expression); + } + else if (ts.isObjectLiteralExpression(node)) { + return ts.some(node.properties, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isArrayLiteralExpression(node)) { + return ts.some(node.elements, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.initializer); + } + else if (ts.isIdentifier(node)) { + var container = resolver.getReferencedExportContainer(node); + return container !== undefined && container.kind === 260 /* SourceFile */; + } + else { + return false; + } + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; + } + // + // Emit Notification + // + /** + * Hook for node emit notifications. + * + * @param emitContext A context hint for the emitter. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260 /* SourceFile */) { + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; + if (noSubstitution) { + delete noSubstitutionMap[id]; + } + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param emitContext A context hint for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (isSubstitutionPrevented(node)) { + return node; + } + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 191 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpressionIdentifier(node) { + // When we see an identifier in an expression position that + // points to an imported symbol, we should substitute a qualified + // reference to the imported symbol if one is needed. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), + /*location*/ node); + } + } + } + return node; + } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 /* PostfixUnaryExpression */ + ? ts.createPrefix(node.operator, node.operand, + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 190 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); + } + return expression; + } + } + return node; + } + /** + * Gets the exports of a name. + * + * @param name The name. + */ + function getExports(name) { + var exportedNames; + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 260 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); + } + } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = ts.createMap(); + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(191 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(189 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(190 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(257 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(260 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. + var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + // Perform the transformation. + var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + } + /** + * Transforms a SourceFile into an AMD or UMD module. + * + * @param node The SourceFile node. + * @param define The expression used to define the module. + * @param moduleName An expression for the module name, if available. + * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. + */ + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ], + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, + /*location*/ currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), + /*location*/ currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + switch (node.kind) { + case 234 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 233 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 240 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + case 204 /* VariableStatement */: + return visitVariableStatement(node); + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 225 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 293 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 294 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.createStatement(createRequireCall(node), /*location*/ node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, + /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ], + /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), + /*location*/ node)); + } + else { + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), + /*location*/ node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + } + else { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + } + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + if (exportName.text === "default") { + var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); + if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; + } + // + // Emit Notification + // + /** + * Hook for node emit notifications. + * + * @param emitContext A context hint for the emitter. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260 /* SourceFile */) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = ts.createMap(); + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param emitContext A context hint for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; + } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); + } + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 191 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 190 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 260 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name_36 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_36), + /*location*/ node); + } + } + } + return node; + } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 /* PostfixUnaryExpression */ + ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); /// /// /// +/// /// /// /// @@ -53978,10 +55767,12 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; transformers.push(ts.transformTypeScript); - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } + if (languageVersion < 5 /* ESNext */) { + transformers.push(ts.transformESNext); + } if (languageVersion < 4 /* ES2017 */) { transformers.push(ts.transformES2017); } @@ -53992,6 +55783,9 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + // The ES5 transformer is last so that it can substitute expressions like `exports.default` + // for ES3. if (languageVersion < 1 /* ES5 */) { transformers.push(ts.transformES5); } @@ -54009,7 +55803,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289 /* Count */); + var enabledSyntaxKindFeatures = new Array(295 /* Count */); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -54409,7 +56203,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 291 /* NotEmittedStatement */ && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -54422,7 +56216,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 291 /* NotEmittedStatement */ && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -54601,7 +56395,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 291 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 16384 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -54620,7 +56414,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 === 220 /* VariableDeclarationList */) { + if (node.kind === 223 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -54930,7 +56724,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 234 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -55004,10 +56798,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219 /* VariableDeclaration */) { + if (declaration.kind === 222 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { + else if (declaration.kind === 237 /* NamedImports */ || declaration.kind === 238 /* ImportSpecifier */ || declaration.kind === 235 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -55025,7 +56819,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 231 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 234 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -55035,12 +56829,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 229 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 229 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -55158,43 +56952,47 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: - case 128 /* NeverKeyword */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 129 /* NeverKeyword */: + case 167 /* ThisType */: + case 170 /* LiteralType */: return writeTextOfNode(currentText, type); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return emitTypeReference(type); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return emitTypeQuery(type); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return emitArrayType(type); - case 162 /* TupleType */: + case 163 /* TupleType */: return emitTupleType(type); - case 163 /* UnionType */: + case 164 /* UnionType */: return emitUnionType(type); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return emitIntersectionType(type); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return emitParenType(type); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 168 /* TypeOperator */: + return emitTypeOperator(type); + case 169 /* IndexedAccessType */: + return emitPropertyAccessType(type); + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return emitEntityName(type); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -55202,8 +57000,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -55212,14 +57010,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 233 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 176 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -55265,6 +57063,17 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitPropertyAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -55298,9 +57107,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_37 = baseName + "_" + count; + if (!(name_37 in currentIdentifiers)) { + return name_37; } } } @@ -55347,10 +57156,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 /* ImportEqualsDeclaration */ || - (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 233 /* ImportEqualsDeclaration */ || + (node.parent.kind === 260 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 260 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -55360,7 +57169,7 @@ var ts; }); } else { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 234 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -55378,23 +57187,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return writeVariableStatement(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return writeClassDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -55402,7 +57211,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 260 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -55411,7 +57220,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 226 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -55463,7 +57272,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 236 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -55487,7 +57296,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 236 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -55508,13 +57317,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 229 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 230 /* ImportEqualsDeclaration */) { + if (parent.kind === 233 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226 /* ModuleDeclaration */) { + else if (parent.kind === 229 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -55584,7 +57393,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227 /* ModuleBlock */) { + while (node.body && node.body.kind !== 230 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -55654,7 +57463,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -55665,15 +57474,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || - node.parent.kind === 147 /* MethodSignature */ || - node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - node.parent.kind === 152 /* CallSignature */ || - node.parent.kind === 153 /* ConstructSignature */); + if (node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || + node.parent.kind === 148 /* MethodSignature */ || + node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + node.parent.kind === 153 /* CallSignature */ || + node.parent.kind === 154 /* ConstructSignature */); emitType(node.constraint); } else { @@ -55684,31 +57493,31 @@ 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 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* CallSignature */: + case 153 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(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 === 222 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 225 /* 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 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -55746,7 +57555,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 222 /* ClassDeclaration */) { + if (node.parent.parent.kind === 225 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -55830,7 +57639,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 222 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -55841,11 +57650,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || - (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || + (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { + if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -55858,14 +57667,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { + else if (node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -55874,7 +57683,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 === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* 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 : @@ -55906,7 +57715,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 197 /* OmittedExpression */) { elements.push(element); } } @@ -55976,7 +57785,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55989,7 +57798,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 150 /* GetAccessor */ + return accessor.kind === 151 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55998,7 +57807,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -56048,17 +57857,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221 /* FunctionDeclaration */) { + if (node.kind === 224 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { + else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 221 /* FunctionDeclaration */) { + if (node.kind === 224 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149 /* Constructor */) { + else if (node.kind === 150 /* Constructor */) { write("constructor"); } else { @@ -56078,17 +57887,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { + if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { write("new "); } - else if (node.kind === 157 /* FunctionType */) { + else if (node.kind === 158 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -56103,22 +57912,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -56132,26 +57941,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 153 /* ConstructSignature */: + case 154 /* 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 152 /* CallSignature */: + case 153 /* 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 154 /* IndexSignature */: + case 155 /* 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 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -56159,7 +57968,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 === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* 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 : @@ -56173,7 +57982,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221 /* FunctionDeclaration */: + case 224 /* 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 : @@ -56208,9 +58017,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - node.parent.parent.kind === 160 /* TypeLiteral */) { + if (node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + node.parent.parent.kind === 161 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -56226,24 +58035,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 149 /* Constructor */: + case 150 /* 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 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: // 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 152 /* CallSignature */: + case 153 /* 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 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -56251,7 +58060,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 === 222 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 225 /* 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 : @@ -56264,7 +58073,7 @@ 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 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: 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 : @@ -56276,12 +58085,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 171 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 172 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -56292,7 +58101,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194 /* OmittedExpression */) { + if (bindingElement.kind === 197 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -56301,7 +58110,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 170 /* BindingElement */) { + else if (bindingElement.kind === 173 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -56340,40 +58149,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 226 /* ModuleDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 223 /* InterfaceDeclaration */: - case 222 /* ClassDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: + case 224 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 226 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return emitExportDeclaration(node); - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return writeFunctionDeclaration(node); - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 154 /* IndexSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 155 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return emitAccessorDeclaration(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return emitSourceFile(node); } } @@ -56464,6 +58273,7 @@ var ts; // This is typically used for JSX spread attributes, // and can be used for object literal spread properties. var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; + var restHelper = "\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))\n t[p] = s[p];\n return t;\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function @@ -56561,6 +58371,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -56754,7 +58565,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: return emitSourceFile(node); } } @@ -56810,210 +58621,216 @@ var ts; case 123 /* DeclareKeyword */: case 124 /* GetKeyword */: case 125 /* IsKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: - case 128 /* NeverKeyword */: - case 129 /* ReadonlyKeyword */: - case 130 /* RequireKeyword */: - case 131 /* NumberKeyword */: - case 132 /* SetKeyword */: - case 133 /* StringKeyword */: - case 134 /* SymbolKeyword */: - case 135 /* TypeKeyword */: - case 136 /* UndefinedKeyword */: - case 137 /* FromKeyword */: - case 138 /* GlobalKeyword */: - case 139 /* OfKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: + case 129 /* NeverKeyword */: + case 130 /* ReadonlyKeyword */: + case 131 /* RequireKeyword */: + case 132 /* NumberKeyword */: + case 133 /* SetKeyword */: + case 134 /* StringKeyword */: + case 135 /* SymbolKeyword */: + case 136 /* TypeKeyword */: + case 137 /* UndefinedKeyword */: + case 138 /* FromKeyword */: + case 139 /* GlobalKeyword */: + case 140 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return emitQualifiedName(node); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return emitTypeParameter(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return emitParameter(node); - case 144 /* Decorator */: + case 145 /* Decorator */: return emitDecorator(node); // Type members - case 145 /* PropertySignature */: + case 146 /* PropertySignature */: return emitPropertySignature(node); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 147 /* MethodSignature */: + case 148 /* MethodSignature */: return emitMethodSignature(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return emitConstructor(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return emitAccessorDeclaration(node); - case 152 /* CallSignature */: + case 153 /* CallSignature */: return emitCallSignature(node); - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: return emitConstructSignature(node); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return emitIndexSignature(node); // Types - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return emitTypePredicate(node); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return emitTypeReference(node); - case 157 /* FunctionType */: + case 158 /* FunctionType */: return emitFunctionType(node); - case 158 /* ConstructorType */: + case 159 /* ConstructorType */: return emitConstructorType(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return emitTypeQuery(node); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return emitTypeLiteral(node); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return emitArrayType(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return emitTupleType(node); - case 163 /* UnionType */: + case 164 /* UnionType */: return emitUnionType(node); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return emitIntersectionType(node); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return emitParenthesizedType(node); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 166 /* ThisType */: + case 167 /* ThisType */: return emitThisType(); - case 167 /* LiteralType */: + case 168 /* TypeOperator */: + return emitTypeOperator(node); + case 169 /* IndexedAccessType */: + return emitPropertyAccessType(node); + case 170 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 171 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 169 /* ArrayBindingPattern */: + case 172 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return emitBindingElement(node); // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return emitTemplateSpan(node); - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 200 /* Block */: + case 203 /* Block */: return emitBlock(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return emitVariableStatement(node); - case 202 /* EmptyStatement */: + case 205 /* EmptyStatement */: return emitEmptyStatement(); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return emitExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return emitIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return emitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return emitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return emitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return emitForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return emitForOfStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return emitContinueStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return emitBreakStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return emitReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return emitWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return emitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return emitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return emitThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return emitTryStatement(node); - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return emitClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return emitModuleBlock(node); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return emitCaseBlock(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return emitImportDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return emitImportClause(node); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return emitNamespaceImport(node); - case 234 /* NamedImports */: + case 237 /* NamedImports */: return emitNamedImports(node); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return emitImportSpecifier(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return emitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return emitExportDeclaration(node); - case 238 /* NamedExports */: + case 241 /* NamedExports */: return emitNamedExports(node); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return emitExportSpecifier(node); - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return; // Module references - case 241 /* ExternalModuleReference */: + case 244 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return emitJsxAttribute(node); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: return emitCaseClause(node); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return emitDefaultClause(node); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return emitHeritageClause(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); + case 258 /* SpreadAssignment */: + return emitSpreadAssignment(node); // Enum - case 255 /* EnumMember */: + case 259 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -57050,65 +58867,65 @@ var ts; writeTokenText(kind); return; // Expressions - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return emitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return emitNewExpression(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return emitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return emitArrowFunction(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return emitDeleteExpression(node); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return emitVoidExpression(node); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return emitAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return emitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return emitConditionalExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return emitTemplateExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return emitYieldExpression(node); - case 192 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 193 /* ClassExpression */: + case 195 /* SpreadElement */: + return emitSpreadExpression(node); + case 196 /* ClassExpression */: return emitClassExpression(node); - case 194 /* OmittedExpression */: + case 197 /* OmittedExpression */: return; - case 196 /* AsExpression */: + case 199 /* AsExpression */: return emitAsExpression(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: return emitJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } @@ -57234,7 +59051,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -57322,6 +59139,17 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitPropertyAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -57508,7 +59336,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 === 186 /* PrefixUnaryExpression */ + return operand.kind === 189 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -57552,7 +59380,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -57626,7 +59454,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 204 /* IfStatement */) { + if (node.elseStatement.kind === 207 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -57688,7 +59516,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220 /* VariableDeclarationList */) { + if (node.kind === 223 /* VariableDeclarationList */) { emit(node); } else { @@ -57927,7 +59755,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226 /* ModuleDeclaration */) { + while (body.kind === 229 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -58167,6 +59995,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } // // Enum // @@ -58252,10 +60086,17 @@ var ts; extendsEmitted = true; helpersEmitted = true; } - if (compilerOptions.jsx !== 1 /* Preserve */ && !assignEmitted && (node.flags & 16384 /* HasJsxSpreadAttributes */)) { + if ((languageVersion < 5 /* ESNext */ || currentSourceFile.scriptKind === 2 /* JSX */ || currentSourceFile.scriptKind === 4 /* TSX */) && + compilerOptions.jsx !== 1 /* Preserve */ && + !assignEmitted && + node.flags & 16384 /* HasSpreadAttribute */) { writeLines(assignHelper); assignEmitted = true; } + if (languageVersion < 5 /* ESNext */ && !restEmitted && node.flags & 32768 /* HasRestAttribute */) { + writeLines(restHelper); + restEmitted = true; + } if (!decorateEmitted && node.flags & 2048 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -58601,7 +60442,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 182 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -58664,10 +60505,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_38 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_38)) { tempFlags |= flags; - return name_41; + return name_38; } } while (true) { @@ -58675,11 +60516,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_39 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_39)) { + return name_39; } } } @@ -58728,17 +60569,17 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 231 /* ImportDeclaration */: - case 237 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: + case 240 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: - case 236 /* ExportAssignment */: + case 224 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: + case 239 /* ExportAssignment */: return generateNameForExportDefault(); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58905,7 +60746,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.2"; + ts.version = "2.1.3"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -59131,11 +60972,11 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_43 = names_2[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_40 = names_1[_i]; + var result = name_40 in cache + ? cache[name_40] + : cache[name_40] = loader(name_40, containingFile); resolutions.push(result); } return resolutions; @@ -59156,7 +60997,7 @@ var ts; // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module. // As all these operations happen - and are nested - within the createProgram call, they close over the below variables. // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses. - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; var currentNodeModulesDepth = 0; // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed. @@ -59173,7 +61014,15 @@ var ts; var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); var resolveModuleNamesWorker; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { + // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. + if (!resolved || resolved.extension !== undefined) { + return resolved; + } + var withExtension = ts.clone(resolved); + withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); + return withExtension; + }); }; } else { var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; @@ -59246,6 +61095,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -59282,6 +61132,112 @@ var ts; } return classifiableNames; } + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + if (!oldProgramState && !file.ambientModuleNames.length) { + // if old program state is not supplied and file does not contain locally defined ambient modules + // then the best we can do is fallback to the default logic + return resolveModuleNamesWorker(moduleNames, containingFile); + } + // at this point we know that either + // - file has local declarations for ambient modules + // OR + // - old program state is available + // OR + // - both of items above + // With this it is possible that we can tell how some module names from the initial list will be resolved + // without doing actual resolution (in particular if some name was resolved to ambient module). + // Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker` + // since we don't want to resolve them again. + // this is a list of modules for which we cannot predict resolution so they should be actually resolved + var unknownModuleNames; + // this is a list of combined results assembles from predicted and resolved results. + // Order in this list matches the order in the original list of module names `moduleNames` which is important + // so later we can split results to resolutions of modules and resolutions of module augmentations. + var result; + // a transient placeholder that is used to mark predicted resolution in the result list + var predictedToResolveToAmbientModuleMarker = {}; + for (var i = 0; i < moduleNames.length; i++) { + var moduleName = moduleNames[i]; + // module name is known to be resolved to ambient module if + // - module name is contained in the list of ambient modules that are locally declared in the file + // - in the old program module name was resolved to ambient module whose declaration is in non-modified file + // (so the same module declaration will land in the new program) + var isKnownToResolveToAmbientModule = false; + if (ts.contains(file.ambientModuleNames, moduleName)) { + isKnownToResolveToAmbientModule = 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); + } + } + else { + isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + } + if (isKnownToResolveToAmbientModule) { + if (!unknownModuleNames) { + // found a first module name for which result can be prediced + // this means that this module name should not be passed to `resolveModuleNamesWorker`. + // We'll use a separate list for module names that are definitely unknown. + result = new Array(moduleNames.length); + // copy all module names that appear before the current one in the list + // since they are known to be unknown + unknownModuleNames = moduleNames.slice(0, i); + } + // mark prediced resolution in the result list + result[i] = predictedToResolveToAmbientModuleMarker; + } + else if (unknownModuleNames) { + // found unknown module name and we are already using separate list for those - add it to the list + unknownModuleNames.push(moduleName); + } + } + if (!unknownModuleNames) { + // we've looked throught the list but have not seen any predicted resolution + // use default logic + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var resolutions = unknownModuleNames.length + ? resolveModuleNamesWorker(unknownModuleNames, containingFile) + : emptyArray; + // combine results of resolutions and predicted results + var j = 0; + for (var i = 0; i < result.length; i++) { + if (result[i] == predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } + else { + result[i] = resolutions[j]; + j++; + } + } + ts.Debug.assert(j === resolutions.length); + return result; + function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { + if (!oldProgramState) { + return false; + } + var resolutionToFile = ts.getResolvedModule(oldProgramState.file, moduleName); + if (resolutionToFile) { + // module used to be resolved to file - ignore it + return false; + } + var ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + if (!(ambientModule && ambientModule.declarations)) { + return false; + } + // at least one of declarations should come from non-modified source file + var firstUnmodifiedFile = ts.forEach(ambientModule.declarations, function (d) { + var f = ts.getSourceFileOfNode(d); + return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && f; + }); + if (!firstUnmodifiedFile) { + return false; + } + if (ts.isTraceEnabled(options, host)) { + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + } + return true; + } + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return false; @@ -59340,29 +61296,8 @@ var ts; // 'types' references has changed return false; } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - // pass the cache of module/types resolutions from the old source file - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + // tentatively approve the file + modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else { // file has no changes - use it as is @@ -59371,15 +61306,42 @@ var ts; // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } + var modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + // try to verify results of module resolution + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths: modifiedFilePaths }); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + // ensure that types resolutions are still correct + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + // pass the cache of module/types resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + for (var _d = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _d < modifiedSourceFiles_2.length; _d++) { + var modifiedFile = modifiedSourceFiles_2[_d]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); oldProgram.structureIsReused = true; @@ -59395,11 +61357,14 @@ var ts; getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, }; } + function isSourceFileFromExternalLibrary(file) { + return sourceFilesFoundSearchingNodeModules[file.path]; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } @@ -59488,6 +61453,14 @@ var ts; } } function getSyntacticDiagnosticsForFile(sourceFile) { + // For JavaScript files, we report semantic errors for using TypeScript-only + // constructs from within a JavaScript file as syntactic errors. + if (ts.isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); + } return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -59516,179 +61489,180 @@ var ts; var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a - // JavaScript file. - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report semantic errors. + // Instead, we'll report errors for using TypeScript-only constructs from within a + // JavaScript file when we get syntactic diagnostics for the file. + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; + var parent = sourceFile; walk(sourceFile); return diagnostics; function walk(node) { - if (!node) { - return false; + // 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 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + if (parent.questionToken === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return; + } + // Pass through + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 222 /* VariableDeclaration */: + // type annotation + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 236 /* ExportAssignment */: + case 233 /* ImportEqualsDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 239 /* ExportAssignment */: if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; } break; - case 222 /* ClassDeclaration */: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return; } break; - case 223 /* InterfaceDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 226 /* ModuleDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 224 /* TypeAliasDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + case 226 /* InterfaceDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 229 /* ModuleDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 227 /* TypeAliasDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 228 /* EnumDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 181 /* TypeAssertionExpression */: + var typeAssertionExpression = node; + diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return; + } + var prevParent = parent; + parent = node; + ts.forEachChild(node, walk, walkArray); + parent = prevParent; + } + function walkArray(nodes) { + if (parent.decorators === nodes && !options.experimentalDecorators) { + 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_to_remove_this_warning)); + } + switch (parent.kind) { + case 225 /* ClassDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + // Check type parameters + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + // pass through + case 204 /* VariableStatement */: + // Check modifiers + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 204 /* VariableStatement */); } break; - case 201 /* VariableStatement */: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 219 /* VariableDeclaration */: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 143 /* Parameter */: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 146 /* PropertyDeclaration */: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + case 147 /* PropertyDeclaration */: + // Check modifiers of property declaration + if (nodes === parent.modifiers) { + for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 114 /* StaticKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } - } - if (checkTypeAnnotation(node.type)) { - return true; + return; } break; - case 225 /* EnumDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 178 /* TypeAssertionExpression */: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 144 /* Decorator */: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + case 144 /* Parameter */: + // Check modifiers of parameter declaration + if (nodes === parent.modifiers) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return; } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: - case 123 /* DeclareKeyword */: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - // These are all legal modifiers. - case 114 /* StaticKeyword */: - case 83 /* ExportKeyword */: - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 116 /* AbstractKeyword */: + break; + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 198 /* ExpressionWithTypeArguments */: + // Check type arguments + if (nodes === parent.typeArguments) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return; } + break; + } + for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { + var node = nodes_4[_b]; + walk(node); + } + } + function checkModifiers(modifiers, isConstValid) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 75 /* ConstKeyword */: + if (isConstValid) { + continue; + } + // Fallthrough to report error + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 130 /* ReadonlyKeyword */: + case 123 /* DeclareKeyword */: + case 116 /* AbstractKeyword */: + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + break; + // These are all legal modifiers. + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: } } - return false; + } + function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) { + var start = nodes.pos; + return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2); + } + // Since these are syntactic diagnostics, parent might not have been set + // this means the sourceFile cannot be infered from the node + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } }); } @@ -59713,9 +61687,6 @@ var ts; ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } @@ -59734,16 +61705,21 @@ var ts; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); var isExternalModuleFile = ts.isExternalModule(file); + var isDtsFile = ts.isDeclarationFile(file); var imports; var moduleAugmentations; + 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) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9 /* StringLiteral */); + // synthesize 'import "tslib"' declaration + var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; + var importDecl = ts.createSynthesizedNode(234 /* ImportDeclaration */); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -59755,12 +61731,13 @@ var ts; } file.imports = imports || emptyArray; file.moduleAugmentations = moduleAugmentations || emptyArray; + file.ambientModuleNames = ambientModules || emptyArray; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -59775,7 +61752,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -59787,6 +61764,10 @@ var ts; (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { + if (isDtsFile) { + // for global .d.ts files record name of ambient module + (ambientModules || (ambientModules = [])).push(moduleName.text); + } // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. @@ -59812,13 +61793,10 @@ var ts; } } } - /** - * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) - */ function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; - if (hasExtension(fileName)) { + if (ts.hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; @@ -59884,7 +61862,7 @@ var ts; processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + if (currentNodeModulesDepth < maxNodeModuleJsDepth) { modulesWithElidedImports[file_1.path] = false; processImportedModules(file_1); } @@ -60004,29 +61982,39 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. + var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9 /* StringLiteral */; }); + var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); + if (!resolution) { + continue; + } + var isFromNodeModulesSearch = resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var resolvedFileName = resolution.resolvedFileName; + if (isFromNodeModulesSearch) { + currentNodeModulesDepth++; + } // add file to program only if: // - resolution was successful // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); - if (isFromNodeModulesSearch) { - currentNodeModulesDepth++; - } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; + // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') + // This may still end up being an untyped module -- the file won't be included but imports will be allowed. + var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); + var pos = ts.skipTrivia(file.text, file.imports[i].pos); + findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -60037,7 +62025,6 @@ var ts; // no imports - drop cached module resolutions file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -60198,7 +62185,15 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + if (options.jsxFactory) { + if (options.reactNamespace) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory")); + } + if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory)); + } + } + else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files @@ -60216,18 +62211,13 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) { - blockEmittingOfFile(emitFileName); - } - else { - var chain_1; - if (!options.configFilePath) { - // The program is from either an inferred project or an external project - chain_1 = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); - } - chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); - blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); + var chain_1; + if (!options.configFilePath) { + // The program is from either an inferred project or an external project + chain_1 = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); } + chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { @@ -60242,12 +62232,38 @@ var ts; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - if (diag) { - programDiagnostics.add(diag); - } + programDiagnostics.add(diag); } } ts.createProgram = createProgram; + /* @internal */ + /** + * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. + * The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. + * This returns a diagnostic even if the module will be an untyped module. + */ + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: + // These are always allowed. + return undefined; + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); + } + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; + } + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + } + } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); /// /// @@ -60328,6 +62344,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -60516,6 +62537,7 @@ var ts; "es2015": 2 /* ES2015 */, "es2016": 3 /* ES2016 */, "es2017": 4 /* ES2017 */, + "esnext": 5 /* ESNext */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -60679,7 +62701,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -60976,11 +62999,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { + for (var name_41 in options) { + if (ts.hasProperty(options, name_41)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_44) { + switch (name_41) { case "init": case "watch": case "version": @@ -60988,14 +63011,14 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name_41]; + var optionDefinition = optionsNameMap[name_41.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_44] = value; + result[name_41] = value; } else { if (optionDefinition.type === "list") { @@ -61004,11 +63027,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name_41] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_41] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -61218,9 +63241,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -61452,6 +63473,7 @@ var ts; // // /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively // /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added + // /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler // // We watch a directory without recursion if it contains a wildcard in the file segment of // the pattern: @@ -61465,14 +63487,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_45 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_45)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_45); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_45) ? 1 /* Recursive */ : 0 /* None */; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -61494,6 +63515,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 /* Recursive */ }; + } + return undefined; + } /** * Determines whether a literal or wildcard file has already been included that has a higher * extension priority. @@ -61597,12 +63631,13 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + var IndentStyle; (function (IndentStyle) { IndentStyle[IndentStyle["None"] = 0] = "None"; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; + })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -61626,14 +63661,14 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; (function (OutputFileType) { OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(ts.OutputFileType || (ts.OutputFileType = {})); - var OutputFileType = ts.OutputFileType; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; (function (EndOfLineState) { EndOfLineState[EndOfLineState["None"] = 0] = "None"; EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; @@ -61642,8 +63677,8 @@ var ts; EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -61654,8 +63689,7 @@ var ts; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; + })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); // TODO: move these to enums var ScriptElementKind; (function (ScriptElementKind) { @@ -61762,6 +63796,7 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; @@ -61787,52 +63822,51 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; + var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; - })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); - var SemanticMeaning = ts.SemanticMeaning; + })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 143 /* Parameter */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: - case 255 /* EnumMember */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 252 /* CatchClause */: + case 144 /* Parameter */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: + case 259 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 255 /* CatchClause */: return 1 /* Value */; - case 142 /* TypeParameter */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 160 /* TypeLiteral */: + case 143 /* TypeParameter */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 161 /* TypeLiteral */: return 2 /* Type */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -61842,22 +63876,22 @@ var ts; else { return 4 /* Namespace */; } - case 234 /* NamedImports */: - case 235 /* ImportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: - case 236 /* ExportAssignment */: - case 237 /* ExportDeclaration */: + case 237 /* NamedImports */: + case 238 /* ImportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 234 /* ImportDeclaration */: + case 239 /* ExportAssignment */: + case 240 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 256 /* SourceFile */: + case 260 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent.kind === 239 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -61882,15 +63916,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 140 /* QualifiedName */ && + if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 233 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 140 /* QualifiedName */) { + while (node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -61901,27 +63935,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 140 /* QualifiedName */) { - while (root.parent && root.parent.kind === 140 /* QualifiedName */) { + if (root.parent.kind === 141 /* QualifiedName */) { + while (root.parent && root.parent.kind === 141 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 156 /* TypeReference */ && !isLastClause; + return root.parent.kind === 157 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 173 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { + if (root.parent.kind === 176 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 176 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 198 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 254 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 225 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 226 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -61929,17 +63963,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 156 /* TypeReference */ || - (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 157 /* TypeReference */ || + (node.parent.kind === 198 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 166 /* ThisType */; + node.kind === 167 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 178 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 179 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -61952,7 +63986,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 218 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -61962,13 +63996,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && + (node.parent.kind === 214 /* BreakStatement */ || node.parent.kind === 213 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 215 /* LabeledStatement */ && + node.parent.kind === 218 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -61976,15 +64010,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 229 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -61995,19 +64029,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 255 /* EnumMember */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 226 /* ModuleDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 259 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 229 /* ModuleDeclaration */: return node.parent.name === node; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return true; } } @@ -62056,17 +64090,17 @@ var ts; return undefined; } switch (node.kind) { - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: return node; } } @@ -62074,46 +64108,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 219 /* VariableDeclaration */: + case 226 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 227 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 228 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 222 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 230 /* ImportEqualsDeclaration */: - case 235 /* ImportSpecifier */: - case 232 /* ImportClause */: - case 239 /* ExportSpecifier */: - case 233 /* NamespaceImport */: + case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 259 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 233 /* ImportEqualsDeclaration */: + case 238 /* ImportSpecifier */: + case 235 /* ImportClause */: + case 242 /* ExportSpecifier */: + case 236 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -62128,7 +64162,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 170 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -62143,7 +64177,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; default: return false; } @@ -62188,42 +64222,42 @@ var ts; return false; } switch (n.kind) { - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 168 /* ObjectBindingPattern */: - case 160 /* TypeLiteral */: - case 200 /* Block */: - case 227 /* ModuleBlock */: - case 228 /* CaseBlock */: - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 171 /* ObjectBindingPattern */: + case 161 /* TypeLiteral */: + case 203 /* Block */: + case 230 /* ModuleBlock */: + case 231 /* CaseBlock */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 176 /* NewExpression */: + case 179 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 175 /* CallExpression */: - case 179 /* ParenthesizedExpression */: - case 165 /* ParenthesizedType */: + case 178 /* CallExpression */: + case 182 /* ParenthesizedExpression */: + case 166 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 181 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 184 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -62233,67 +64267,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 204 /* IfStatement */: + case 207 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 171 /* ArrayLiteralExpression */: - case 169 /* ArrayBindingPattern */: - case 174 /* ElementAccessExpression */: - case 141 /* ComputedPropertyName */: - case 162 /* TupleType */: + case 174 /* ArrayLiteralExpression */: + case 172 /* ArrayBindingPattern */: + case 177 /* ElementAccessExpression */: + case 142 /* ComputedPropertyName */: + case 163 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 205 /* DoStatement */: + case 208 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 183 /* TypeOfExpression */: - case 182 /* DeleteExpression */: - case 184 /* VoidExpression */: - case 191 /* YieldExpression */: - case 192 /* SpreadElementExpression */: + case 186 /* TypeOfExpression */: + case 185 /* DeleteExpression */: + case 187 /* VoidExpression */: + case 194 /* YieldExpression */: + case 195 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 237 /* ExportDeclaration */: - case 231 /* ImportDeclaration */: + case 240 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -62349,7 +64383,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 286 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 290 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -62521,7 +64555,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 260 /* SourceFile */); // 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. @@ -62580,17 +64614,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 251 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxClosingElement */) { return true; } return false; @@ -62702,17 +64736,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { + if (node.kind === 157 /* TypeReference */ || node.kind === 178 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 225 /* ClassDeclaration */ || node.kind === 226 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -62771,18 +64805,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 /* ArrayLiteralExpression */ || - node.kind === 172 /* ObjectLiteralExpression */) { + if (node.kind === 174 /* ArrayLiteralExpression */ || + node.kind === 175 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 188 /* BinaryExpression */ && + if (node.parent.kind === 191 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 209 /* ForOfStatement */ && + if (node.parent.kind === 212 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -62790,7 +64824,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 256 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -62823,7 +64857,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -63003,7 +65037,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 141 /* ComputedPropertyName */) { + location.parent.kind === 142 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -63015,7 +65049,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && + (location.parent.kind === 238 /* ImportSpecifier */ || location.parent.kind === 242 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -63087,7 +65121,7 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// we have a series of divide operator. this list allows us to be more accurate by ruling out @@ -63130,7 +65164,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 132 /* SetKeyword */ || + keyword2 === 133 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -63289,10 +65323,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 133 /* StringKeyword */ || - token === 131 /* NumberKeyword */ || + token === 134 /* StringKeyword */ || + token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 134 /* SymbolKeyword */) { + token === 135 /* 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, @@ -63464,7 +65498,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -63521,10 +65555,10 @@ 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 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -63575,7 +65609,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ModuleDeclaration */ && + return declaration.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -63654,8 +65688,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -63739,16 +65773,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 275 /* JSDocParameterTag */: + case 279 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 278 /* JSDocTemplateTag */: + case 282 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 277 /* JSDocTypeTag */: + case 281 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 276 /* JSDocReturnTag */: + case 280 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -63835,22 +65869,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -63878,17 +65912,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 219 /* VariableDeclaration */ || - token.parent.kind === 146 /* PropertyDeclaration */ || - token.parent.kind === 143 /* Parameter */ || - token.parent.kind === 246 /* JsxAttribute */) { + if (token.parent.kind === 222 /* VariableDeclaration */ || + token.parent.kind === 147 /* PropertyDeclaration */ || + token.parent.kind === 144 /* Parameter */ || + token.parent.kind === 249 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 188 /* BinaryExpression */ || - token.parent.kind === 186 /* PrefixUnaryExpression */ || - token.parent.kind === 187 /* PostfixUnaryExpression */ || - token.parent.kind === 189 /* ConditionalExpression */) { + if (token.parent.kind === 191 /* BinaryExpression */ || + token.parent.kind === 189 /* PrefixUnaryExpression */ || + token.parent.kind === 190 /* PostfixUnaryExpression */ || + token.parent.kind === 192 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -63898,7 +65932,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 249 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -63914,32 +65948,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 143 /* Parameter */: + case 144 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -63999,7 +66033,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 245 /* JsxClosingElement */) { + location.parent && location.parent.kind === 248 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -64026,14 +66060,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { + for (var name_42 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_46] === position) { + if (nameTable[name_42] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_42]) { + uniqueNames[name_42] = name_42; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_42), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -64093,8 +66127,8 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && + if (node.parent.kind === 256 /* PropertyAssignment */ && + node.parent.parent.kind === 175 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -64119,7 +66153,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 231 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 234 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -64510,8 +66544,8 @@ var ts; } catch (e) { } if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; + for (var _b = 0, typeRoots_3 = typeRoots; _b < typeRoots_3.length; _b++) { + var root = typeRoots_3[_b]; getCompletionEntriesFromDirectories(host, root, span, result); } } @@ -64546,11 +66580,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_15 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_15) { break; } - currentDir = parent_16; + currentDir = parent_15; } else { break; @@ -64702,9 +66736,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277 /* JSDocTypeTag */: - case 275 /* JSDocParameterTag */: - case 276 /* JSDocReturnTag */: + case 281 /* JSDocTypeTag */: + case 279 /* JSDocParameterTag */: + case 280 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -64749,13 +66783,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_16 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_17.kind === 173 /* PropertyAccessExpression */) { + if (parent_16.kind === 176 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140 /* QualifiedName */) { + else if (parent_16.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -64770,7 +66804,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 248 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -64819,7 +66853,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 176 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -64875,7 +66909,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 246 /* JsxSelfClosingElement */) || (jsxContainer.kind === 247 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -64923,9 +66957,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 /* SourceFile */ || - scopeNode.kind === 190 /* TemplateExpression */ || - scopeNode.kind === 248 /* JsxExpression */ || + scopeNode.kind === 260 /* SourceFile */ || + scopeNode.kind === 193 /* TemplateExpression */ || + scopeNode.kind === 251 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -64958,11 +66992,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 247 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; + if (contextToken.parent.kind === 248 /* JsxClosingElement */ || contextToken.parent.kind === 246 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 245 /* JsxElement */; } } return false; @@ -64972,40 +67006,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 175 /* CallExpression */ // func( a, | - || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 176 /* NewExpression */ // new C(a, | - || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 178 /* CallExpression */ // func( a, | + || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 179 /* NewExpression */ // new C(a, | + || containingNodeKind === 174 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 191 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 175 /* CallExpression */ // func( | - || containingNodeKind === 149 /* Constructor */ // constructor( | - || containingNodeKind === 176 /* NewExpression */ // new C(a| - || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 178 /* CallExpression */ // func( | + || containingNodeKind === 150 /* Constructor */ // constructor( | + || containingNodeKind === 179 /* NewExpression */ // new C(a| + || containingNodeKind === 182 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 126 /* ModuleKeyword */: // module | - case 127 /* NamespaceKeyword */: + return containingNodeKind === 174 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 127 /* ModuleKeyword */: // module | + case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 229 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 225 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 188 /* BinaryExpression */; // x = a| + return containingNodeKind === 222 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 191 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 193 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 201 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -65048,7 +67082,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 175 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -65058,7 +67092,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 171 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -65069,11 +67103,11 @@ var ts; // 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 = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -65115,9 +67149,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? - 231 /* ImportDeclaration */ : - 237 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 237 /* NamedImports */ ? + 234 /* ImportDeclaration */ : + 240 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -65142,9 +67176,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { - return parent_18; + var parent_17 = contextToken.parent; + if (parent_17 && (parent_17.kind === 175 /* ObjectLiteralExpression */ || parent_17.kind === 171 /* ObjectBindingPattern */)) { + return parent_17; } break; } @@ -65161,8 +67195,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return contextToken.parent; } } @@ -65171,37 +67205,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_18 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { - return parent_19; + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: + if (parent_18 && (parent_18.kind === 246 /* JsxSelfClosingElement */ || parent_18.kind === 247 /* JsxOpeningElement */)) { + return parent_18; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_18.kind === 249 /* JsxAttribute */) { + return parent_18.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { - return parent_19.parent; + if (parent_18 && ((parent_18.kind === 249 /* JsxAttribute */) || (parent_18.kind === 250 /* JsxSpreadAttribute */))) { + return parent_18.parent; } break; case 17 /* CloseBraceToken */: - if (parent_19 && - parent_19.kind === 248 /* JsxExpression */ && - parent_19.parent && - (parent_19.parent.kind === 246 /* JsxAttribute */)) { - return parent_19.parent.parent; + if (parent_18 && + parent_18.kind === 251 /* JsxExpression */ && + parent_18.parent && + (parent_18.parent.kind === 249 /* JsxAttribute */)) { + return parent_18.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_18 && parent_18.kind === 250 /* JsxSpreadAttribute */) { + return parent_18.parent; } break; } @@ -65210,16 +67244,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return true; } return false; @@ -65231,66 +67265,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 219 /* VariableDeclaration */ || - containingNodeKind === 220 /* VariableDeclarationList */ || - containingNodeKind === 201 /* VariableStatement */ || - containingNodeKind === 225 /* EnumDeclaration */ || + return containingNodeKind === 222 /* VariableDeclaration */ || + containingNodeKind === 223 /* VariableDeclarationList */ || + containingNodeKind === 204 /* VariableStatement */ || + containingNodeKind === 228 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 169 /* ArrayBindingPattern */ || - containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 225 /* ClassDeclaration */ || + containingNodeKind === 196 /* ClassExpression */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 172 /* ArrayBindingPattern */ || + containingNodeKind === 227 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 172 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 170 /* BindingElement */; // var {x :html| + return containingNodeKind === 173 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 172 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 252 /* CatchClause */ || + return containingNodeKind === 255 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 225 /* EnumDeclaration */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* TypeLiteral */; // const x : { | + return containingNodeKind === 228 /* EnumDeclaration */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 145 /* PropertySignature */ && + return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 226 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 224 /* TypeAliasDeclaration */ || + return containingNodeKind === 225 /* ClassDeclaration */ || + containingNodeKind === 196 /* ClassExpression */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 227 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 146 /* PropertyDeclaration */; + return containingNodeKind === 147 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 143 /* Parameter */ || + return containingNodeKind === 144 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 172 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 143 /* Parameter */; + return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 235 /* ImportSpecifier */ || - containingNodeKind === 239 /* ExportSpecifier */ || - containingNodeKind === 233 /* NamespaceImport */; + return containingNodeKind === 238 /* ImportSpecifier */ || + containingNodeKind === 242 /* ExportSpecifier */ || + containingNodeKind === 236 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 132 /* SetKeyword */: + case 133 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -65338,8 +67372,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name_43 = element.propertyName || element.name; + existingImportsOrExports[name_43.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -65360,10 +67394,12 @@ 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 !== 253 /* PropertyAssignment */ && - m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 170 /* BindingElement */ && - m.kind !== 148 /* MethodDeclaration */) { + if (m.kind !== 256 /* PropertyAssignment */ && + m.kind !== 257 /* ShorthandPropertyAssignment */ && + m.kind !== 173 /* BindingElement */ && + m.kind !== 149 /* MethodDeclaration */ && + m.kind !== 151 /* GetAccessor */ && + m.kind !== 152 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -65371,7 +67407,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 170 /* BindingElement */ && m.propertyName) { + if (m.kind === 173 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -65401,7 +67437,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246 /* JsxAttribute */) { + if (attr.kind === 249 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -65451,7 +67487,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -65528,7 +67564,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 70 /* Identifier */ || node.kind === 98 /* ThisKeyword */ || - node.kind === 166 /* ThisType */ || + node.kind === 167 /* ThisType */ || node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { @@ -65582,75 +67618,75 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 204 /* IfStatement */)) { + if (hasKind(node.parent, 207 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 212 /* ReturnStatement */)) { + if (hasKind(node.parent, 215 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 216 /* ThrowStatement */)) { + if (hasKind(node.parent, 219 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 220 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 217 /* TryStatement */)) { + if (hasKind(parent(node), 220 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 214 /* SwitchStatement */)) { + if (hasKind(node.parent, 217 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 217 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { + if (hasKind(node.parent, 214 /* BreakStatement */) || hasKind(node.parent, 213 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 207 /* ForStatement */) || - hasKind(node.parent, 208 /* ForInStatement */) || - hasKind(node.parent, 209 /* ForOfStatement */)) { + if (hasKind(node.parent, 210 /* ForStatement */) || + hasKind(node.parent, 211 /* ForInStatement */) || + hasKind(node.parent, 212 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { + if (hasKind(node.parent, 209 /* WhileStatement */) || hasKind(node.parent, 208 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 149 /* Constructor */)) { + if (hasKind(node.parent, 150 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 124 /* GetKeyword */: - case 132 /* SetKeyword */: - if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { + case 133 /* SetKeyword */: + if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 204 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -65666,10 +67702,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216 /* ThrowStatement */) { + if (node.kind === 219 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 217 /* TryStatement */) { + else if (node.kind === 220 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -65696,19 +67732,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { - return parent_20; + var parent_19 = child.parent; + if (ts.isFunctionBlock(parent_19) || parent_19.kind === 260 /* SourceFile */) { + return parent_19; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_20.kind === 217 /* TryStatement */) { - var tryStatement = parent_20; + if (parent_19.kind === 220 /* TryStatement */) { + var tryStatement = parent_19; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_19; } return undefined; } @@ -65717,7 +67753,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { + if (node.kind === 214 /* BreakStatement */ || node.kind === 213 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -65732,16 +67768,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 214 /* SwitchStatement */: - if (statement.kind === 210 /* ContinueStatement */) { + case 217 /* SwitchStatement */: + if (statement.kind === 213 /* ContinueStatement */) { continue; } // Fall through. - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -65760,24 +67796,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 222 /* ClassDeclaration */ || - container.kind === 193 /* ClassExpression */ || - (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { + if (!(container.kind === 225 /* ClassDeclaration */ || + container.kind === 196 /* ClassExpression */ || + (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { + if (!(container.kind === 225 /* ClassDeclaration */ || container.kind === 196 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + if (!(container.kind === 230 /* ModuleBlock */ || container.kind === 260 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { + if (!(container.kind === 225 /* ClassDeclaration */ || declaration.kind === 225 /* ClassDeclaration */)) { return undefined; } } @@ -65789,8 +67825,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: + case 230 /* ModuleBlock */: + case 260 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -65799,17 +67835,17 @@ var ts; nodes = container.statements; } break; - case 149 /* Constructor */: + case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: 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. if (modifierFlag & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 149 /* Constructor */ && member; + return member.kind === 150 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -65862,13 +67898,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 133 /* SetKeyword */); }); } } } @@ -65886,7 +67922,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 205 /* DoStatement */) { + if (loopNode.kind === 208 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -65907,13 +67943,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -65967,7 +68003,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 200 /* Block */))) { + if (!(func && hasKind(func.body, 203 /* Block */))) { return undefined; } var keywords = []; @@ -65983,7 +68019,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 204 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 207 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -65996,7 +68032,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 207 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -66039,7 +68075,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 218 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -66273,12 +68309,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 235 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || - declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 238 /* ImportSpecifier */ || + declaration.kind === 242 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -66286,7 +68322,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 238 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -66301,14 +68337,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 173 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 171 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 173 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -66338,14 +68374,14 @@ 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 valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 183 /* FunctionExpression */ || valueDeclaration.kind === 196 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 225 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -66376,7 +68412,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 260 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -66407,8 +68443,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -66580,14 +68616,14 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149 /* Constructor */); + ts.Debug.assert(decl.kind === 150 /* Constructor */); var ctrKeyword = decl.getChildAt(0); ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 148 /* MethodDeclaration */) { + if (decl && decl.kind === 149 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { @@ -66610,7 +68646,7 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149 /* Constructor */); + ts.Debug.assert(decl.kind === 150 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { @@ -66652,7 +68688,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 257 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -66665,24 +68701,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_21 = containingTypeReference.parent; - if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); + var parent_20 = containingTypeReference.parent; + if (ts.isVariableLike(parent_20) && parent_20.type === containingTypeReference && parent_20.initializer && isImplementationExpression(parent_20.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_20.initializer)); } - else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 200 /* Block */) { - ts.forEachReturnStatement(parent_21.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_20) && parent_20.type === containingTypeReference && parent_20.body) { + if (parent_20.body.kind === 203 /* Block */) { + ts.forEachReturnStatement(parent_20.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_21.body)) { - maybeAdd(getReferenceEntryFromNode(parent_21.body)); + else if (isImplementationExpression(parent_20.body)) { + maybeAdd(getReferenceEntryFromNode(parent_20.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_20) && isImplementationExpression(parent_20.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_20.expression)); } } } @@ -66722,12 +68758,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ - && node.parent.kind === 251 /* HeritageClause */ + if (node.kind === 198 /* ExpressionWithTypeArguments */ + && node.parent.kind === 254 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 176 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -66738,14 +68774,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 182 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 181 /* ArrowFunction */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 172 /* ObjectLiteralExpression */ || - node.kind === 193 /* ClassExpression */ || - node.kind === 171 /* ArrayLiteralExpression */; + return node.kind === 184 /* ArrowFunction */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 175 /* ObjectLiteralExpression */ || + node.kind === 196 /* ClassExpression */ || + node.kind === 174 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -66794,7 +68830,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 226 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -66822,13 +68858,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -66860,27 +68896,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 183 /* 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. @@ -66889,7 +68925,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256 /* SourceFile */) { + if (searchSpaceNode.kind === 260 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -66923,28 +68959,28 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 256 /* SourceFile */: - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + case 260 /* SourceFile */: + if (container.kind === 260 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -66998,7 +69034,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 257 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -67046,7 +69082,7 @@ var ts; // we should include both parameter declaration symbol and property declaration symbol // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -67101,7 +69137,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 226 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -67185,7 +69221,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -67267,7 +69303,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219 /* VariableDeclaration */) { + else if (node.kind === 222 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -67277,18 +69313,18 @@ var ts; } else { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 204 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 223 /* VariableDeclarationList */); return node.parent.parent; } } @@ -67327,10 +69363,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { + if (parent.kind === 190 /* PostfixUnaryExpression */ || parent.kind === 189 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 191 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -67352,7 +69388,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 141 /* ComputedPropertyName */) { + if (node.parent.kind === 142 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through @@ -67363,11 +69399,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return true; } return false; @@ -67442,7 +69478,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { + (declaration.kind === 238 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 237 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -67451,7 +69487,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 === 254 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 257 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -67534,8 +69570,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 149 /* Constructor */) || - (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 150 /* Constructor */) || + (!selectConstructors && (d.kind === 224 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -67615,7 +69651,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // 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 === 254 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 257 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -67781,19 +69817,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: - case 222 /* ClassDeclaration */: - case 201 /* VariableStatement */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: + case 225 /* ClassDeclaration */: + case 204 /* VariableStatement */: break findOwner; - case 256 /* SourceFile */: + case 260 /* SourceFile */: return undefined; - case 226 /* ModuleDeclaration */: + case 229 /* 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 { }'. - if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 229 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -67834,7 +69870,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201 /* VariableStatement */) { + if (commentOwner.kind === 204 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -67852,17 +69888,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 182 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return rightHandSide.parameters; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* Constructor */) { + if (member.kind === 150 /* Constructor */) { return member.parameters; } } @@ -67929,7 +69965,7 @@ var ts; mergeTypings(typingOptions.include); exclude = typingOptions.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { + if (projectRootPath) { possibleSearchDirs.push(projectRootPath); } searchDirs = ts.deduplicate(possibleSearchDirs); @@ -67954,9 +69990,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_48 in packageNameToTypingLocation) { - if (name_48 in inferredTypings && !inferredTypings[name_48]) { - inferredTypings[name_48] = packageNameToTypingLocation[name_48]; + for (var name_44 in packageNameToTypingLocation) { + if (name_44 in inferredTypings && !inferredTypings[name_44]) { + inferredTypings[name_44] = packageNameToTypingLocation[name_44]; } } // Remove typings that the user has added to the exclude list @@ -68094,12 +70130,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_49 in nameToDeclarations) { - var declarations = nameToDeclarations[name_49]; + for (var name_45 in nameToDeclarations) { + var declarations = nameToDeclarations[name_45]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_45); if (!matches) { continue; } @@ -68112,14 +70148,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_49); + matches = patternMatcher.getMatches(containers, name_45); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_45, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -68127,7 +70163,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { + if (decl.kind === 235 /* ImportClause */ || decl.kind === 238 /* ImportSpecifier */ || decl.kind === 233 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -68169,7 +70205,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 141 /* ComputedPropertyName */) { + else if (declaration.name.kind === 142 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -68190,7 +70226,7 @@ var ts; } return true; } - if (expression.kind === 173 /* PropertyAccessExpression */) { + if (expression.kind === 176 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -68203,7 +70239,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 141 /* ComputedPropertyName */) { + if (declaration.name.kind === 142 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -68356,7 +70392,7 @@ var ts; return; } switch (node.kind) { - case 149 /* Constructor */: + case 150 /* 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); @@ -68368,21 +70404,21 @@ var ts; } } break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 148 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 232 /* ImportClause */: + case 235 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -68394,7 +70430,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 236 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -68405,12 +70441,12 @@ var ts; } } break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 222 /* VariableDeclaration */: var decl = node; - var name_50 = decl.name; - if (ts.isBindingPattern(name_50)) { - addChildrenRecursively(name_50); + var name_46 = decl.name; + if (ts.isBindingPattern(name_46)) { + addChildrenRecursively(name_46); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -68420,12 +70456,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -68435,9 +70471,9 @@ var ts; } endNode(); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -68445,21 +70481,21 @@ var ts; } endNode(); break; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239 /* ExportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 154 /* IndexSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 224 /* TypeAliasDeclaration */: + case 242 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 155 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 227 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279 /* JSDocTypedefTag */) { + if (tag.kind === 283 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -68510,14 +70546,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 226 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 229 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 226 /* ModuleDeclaration */) { + if (a.body.kind !== 229 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -68577,7 +70613,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -68585,18 +70621,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 196 /* ClassExpression */: return getFunctionOrClassName(node); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -68607,16 +70643,16 @@ var ts; } } switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -68624,15 +70660,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return "constructor"; - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: return "new()"; - case 152 /* CallSignature */: + case 153 /* CallSignature */: return "()"; - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return "[]"; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -68644,7 +70680,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 204 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -68673,24 +70709,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: - case 224 /* TypeAliasDeclaration */: - case 279 /* JSDocTypedefTag */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 227 /* TypeAliasDeclaration */: + case 283 /* JSDocTypedefTag */: return true; - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 219 /* VariableDeclaration */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 222 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -68700,10 +70736,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: + case 230 /* ModuleBlock */: + case 260 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -68712,7 +70748,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; + return childKind !== 222 /* VariableDeclaration */ && childKind !== 173 /* BindingElement */; }); } } @@ -68770,7 +70806,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 229 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -68781,13 +70817,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 229 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 141 /* ComputedPropertyName */; + return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 256 /* SourceFile */ + return node.kind === 260 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -68795,14 +70831,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 219 /* VariableDeclaration */) { + else if (node.parent.kind === 222 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 /* BinaryExpression */ && + else if (node.parent.kind === 191 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 256 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -68813,7 +70849,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; + return node.kind === 183 /* FunctionExpression */ || node.kind === 184 /* ArrowFunction */ || node.kind === 196 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -68903,7 +70939,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 184 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -68915,30 +70951,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200 /* Block */: + case 203 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_21 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_22.kind === 205 /* DoStatement */ || - parent_22.kind === 208 /* ForInStatement */ || - parent_22.kind === 209 /* ForOfStatement */ || - parent_22.kind === 207 /* ForStatement */ || - parent_22.kind === 204 /* IfStatement */ || - parent_22.kind === 206 /* WhileStatement */ || - parent_22.kind === 213 /* WithStatement */ || - parent_22.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + if (parent_21.kind === 208 /* DoStatement */ || + parent_21.kind === 211 /* ForInStatement */ || + parent_21.kind === 212 /* ForOfStatement */ || + parent_21.kind === 210 /* ForStatement */ || + parent_21.kind === 207 /* IfStatement */ || + parent_21.kind === 209 /* WhileStatement */ || + parent_21.kind === 216 /* WithStatement */ || + parent_21.kind === 255 /* CatchClause */) { + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217 /* TryStatement */) { + if (parent_21.kind === 220 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_22; + var tryStatement = parent_21; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -68961,23 +70997,23 @@ var ts; break; } // Fallthrough. - case 227 /* ModuleBlock */: { + case 230 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 228 /* CaseBlock */: { + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 231 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -68997,13 +71033,13 @@ var ts; var ts; (function (ts) { // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. + var PatternMatchKind; (function (PatternMatchKind) { PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; + })(PatternMatchKind = ts.PatternMatchKind || (ts.PatternMatchKind = {})); function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { return { kind: kind, @@ -69334,7 +71370,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 5 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -69347,7 +71383,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 5 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -69625,7 +71661,7 @@ var ts; if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 126 /* ModuleKeyword */) { + if (token === 127 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -69650,7 +71686,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -69681,7 +71717,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -69697,7 +71733,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -69727,7 +71763,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -69739,7 +71775,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -69764,7 +71800,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 130 /* RequireKeyword */) { + if (token === 131 /* RequireKeyword */) { token = nextToken(); if (token === 18 /* OpenParenToken */) { token = nextToken(); @@ -70119,12 +72155,12 @@ var ts; // return null; // } var emptyArray = []; + var ArgumentListKind; (function (ArgumentListKind) { ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; - })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); - var ArgumentListKind = SignatureHelp.ArgumentListKind; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -70155,7 +72191,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 178 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -70163,7 +72199,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 173 /* PropertyAccessExpression */ + : expression.kind === 176 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -70196,7 +72232,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { + if (node.parent.kind === 178 /* CallExpression */ || node.parent.kind === 179 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -70250,25 +72286,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 180 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 180 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 193 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 201 /* TemplateSpan */ && node.parent.parent.parent.kind === 180 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 193 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -70386,7 +72422,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 === 190 /* TemplateExpression */) { + if (template.kind === 193 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -70395,7 +72431,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 256 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 260 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -70455,7 +72491,9 @@ var ts; if (callTargetDisplayParts) { ts.addRange(prefixDisplayParts, callTargetDisplayParts); } + var isVariadic; if (isTypeParameterList) { + isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; @@ -70466,6 +72504,7 @@ var ts; ts.addRange(suffixDisplayParts, parameterParts); } else { + isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); @@ -70480,7 +72519,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], @@ -70537,7 +72576,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 196 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -70643,7 +72682,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 173 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 176 /* 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)) { @@ -70652,7 +72691,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { + if (location.kind === 178 /* CallExpression */ || location.kind === 179 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -70665,7 +72704,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 179 /* NewExpression */ || callExpression.expression.kind === 96 /* 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 @@ -70718,24 +72757,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 149 /* Constructor */) { + if (functionDeclaration.kind === 150 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -70744,7 +72783,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 196 /* 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 @@ -70767,7 +72806,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -70788,9 +72827,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 229 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -70811,17 +72850,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 153 /* ConstructSignature */) { + if (declaration.kind === 154 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -70830,7 +72869,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -70841,7 +72880,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255 /* EnumMember */) { + if (declaration.kind === 259 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -70853,10 +72892,10 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 232 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); } else { displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); @@ -70864,13 +72903,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230 /* ImportEqualsDeclaration */) { + if (declaration.kind === 233 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(131 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); @@ -70937,10 +72976,10 @@ var ts; // For some special property access expressions like `experts.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 === 256 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 260 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 191 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -71016,16 +73055,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 180 /* FunctionExpression */) { + if (declaration.kind === 183 /* FunctionExpression */) { return true; } - if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { + if (declaration.kind !== 222 /* VariableDeclaration */ && declaration.kind !== 224 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { + for (var parent_22 = declaration.parent; !ts.isFunctionBlock(parent_22); parent_22 = parent_22.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { + if (parent_22.kind === 260 /* SourceFile */ || parent_22.kind === 230 /* ModuleBlock */) { return false; } } @@ -71136,7 +73175,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -71155,7 +73194,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_4(opt); } return options; } @@ -71167,8 +73206,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -71263,10 +73302,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 246 /* JsxAttribute */: - case 244 /* JsxOpeningElement */: - case 245 /* JsxClosingElement */: - case 243 /* JsxSelfClosingElement */: + case 249 /* JsxAttribute */: + case 247 /* JsxOpeningElement */: + case 248 /* JsxClosingElement */: + case 246 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -71501,14 +73540,14 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var FormattingRequestKind; (function (FormattingRequestKind) { FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; - })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); - var FormattingRequestKind = formatting.FormattingRequestKind; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71540,13 +73579,13 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var RuleAction; (function (RuleAction) { RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; RuleAction[RuleAction["Space"] = 2] = "Space"; RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; RuleAction[RuleAction["Delete"] = 8] = "Delete"; - })(formatting.RuleAction || (formatting.RuleAction = {})); - var RuleAction = formatting.RuleAction; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71587,11 +73626,11 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var RuleFlags; (function (RuleFlags) { RuleFlags[RuleFlags["None"] = 0] = "None"; RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; - })(formatting.RuleFlags || (formatting.RuleFlags = {})); - var RuleFlags = formatting.RuleFlags; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71742,7 +73781,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -71750,10 +73789,10 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 137 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -71773,7 +73812,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -71901,9 +73940,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_51 in o) { - if (o[name_51] === rule) { - return name_51; + for (var name_47 in o) { + if (o[name_47] === rule) { + return name_47; } } throw new Error("Unknown rule"); @@ -71912,42 +73951,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 207 /* ForStatement */; + return context.contextNode.kind === 210 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188 /* BinaryExpression */: - case 189 /* ConditionalExpression */: - case 196 /* AsExpression */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: - case 155 /* TypePredicate */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 191 /* BinaryExpression */: + case 192 /* ConditionalExpression */: + case 199 /* AsExpression */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 156 /* TypePredicate */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 170 /* BindingElement */: + case 173 /* BindingElement */: // equals in type X = ... - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: // equal in p = 0; - case 143 /* Parameter */: - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 259 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 209 /* ForOfStatement */: - return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; + case 212 /* ForOfStatement */: + return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; }; @@ -71955,7 +73994,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189 /* ConditionalExpression */; + return context.contextNode.kind === 192 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -71999,97 +74038,97 @@ var ts; return true; } switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 172 /* ObjectLiteralExpression */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 175 /* ObjectLiteralExpression */: + case 230 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 152 /* CallSignature */: - case 180 /* FunctionExpression */: - case 149 /* Constructor */: - case 181 /* ArrowFunction */: + case 153 /* CallSignature */: + case 183 /* FunctionExpression */: + case 150 /* Constructor */: + case 184 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; + return context.contextNode.kind === 224 /* FunctionDeclaration */ || context.contextNode.kind === 183 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 160 /* TypeLiteral */: - case 226 /* ModuleDeclaration */: - case 237 /* ExportDeclaration */: - case 238 /* NamedExports */: - case 231 /* ImportDeclaration */: - case 234 /* NamedImports */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 161 /* TypeLiteral */: + case 229 /* ModuleDeclaration */: + case 240 /* ExportDeclaration */: + case 241 /* NamedExports */: + case 234 /* ImportDeclaration */: + case 237 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 222 /* ClassDeclaration */: - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: - case 200 /* Block */: - case 252 /* CatchClause */: - case 227 /* ModuleBlock */: - case 214 /* SwitchStatement */: + case 225 /* ClassDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: + case 203 /* Block */: + case 255 /* CatchClause */: + case 230 /* ModuleBlock */: + case 217 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 204 /* IfStatement */: - case 214 /* SwitchStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 217 /* TryStatement */: - case 205 /* DoStatement */: - case 213 /* WithStatement */: + case 207 /* IfStatement */: + case 217 /* SwitchStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: + case 220 /* TryStatement */: + case 208 /* DoStatement */: + case 216 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 252 /* CatchClause */: + case 255 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172 /* ObjectLiteralExpression */; + return context.contextNode.kind === 175 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175 /* CallExpression */; + return context.contextNode.kind === 178 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176 /* NewExpression */; + return context.contextNode.kind === 179 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -72101,25 +74140,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181 /* ArrowFunction */; + return context.contextNode.kind === 184 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242 /* JsxElement */; + return context.contextNode.kind !== 245 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248 /* JsxExpression */; + return context.contextNode.kind === 251 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246 /* JsxAttribute */; + return context.nextTokenParent.kind === 249 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246 /* JsxAttribute */; + return context.contextNode.kind === 249 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243 /* JsxSelfClosingElement */; + return context.contextNode.kind === 246 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -72134,41 +74173,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 144 /* Decorator */; + return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 220 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 223 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 226 /* ModuleDeclaration */; + return context.contextNode.kind === 229 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 156 /* TypeReference */: - case 178 /* TypeAssertionExpression */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 195 /* ExpressionWithTypeArguments */: + case 157 /* TypeReference */: + case 181 /* TypeAssertionExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 198 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -72179,13 +74218,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178 /* TypeAssertionExpression */; + return context.contextNode.kind === 181 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 187 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 194 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -72209,7 +74248,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 139 /* LastToken */ + 1; + this.mapRowLength = 140 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); // new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); // new Array(this.map.length); @@ -72223,7 +74262,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -72260,6 +74299,7 @@ var ts; formatting.RulesMap = RulesMap; var MaskBitSize = 5; var Mask = 0x1f; + var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; @@ -72267,8 +74307,7 @@ var ts; RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; + })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); var RulesBucketConstructionState = (function () { function RulesBucketConstructionState() { //// The Rules list contains all the inserted rules into a rulebucket in the following order: @@ -72404,7 +74443,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { result.push(token); } return result; @@ -72448,9 +74487,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -72458,7 +74497,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -72717,17 +74756,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 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 256 /* SourceFile */: - case 200 /* Block */: - case 227 /* ModuleBlock */: + return body && body.kind === 230 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 260 /* SourceFile */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -72932,20 +74971,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; - case 150 /* GetAccessor */: return 124 /* GetKeyword */; - case 151 /* SetAccessor */: return 132 /* SetKeyword */; - case 148 /* MethodDeclaration */: + case 225 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 226 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 224 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 228 /* EnumDeclaration */: return 228 /* EnumDeclaration */; + case 151 /* GetAccessor */: return 124 /* GetKeyword */; + case 152 /* SetAccessor */: return 133 /* SetKeyword */; + case 149 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: return node.name.kind; } } @@ -73089,11 +75128,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 174 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -73438,12 +75477,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 149 /* Constructor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 181 /* ArrowFunction */: + case 150 /* Constructor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 184 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -73451,8 +75490,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73460,7 +75499,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73576,7 +75615,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 191 /* 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 */) { @@ -73699,7 +75738,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 === 256 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 260 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -73732,7 +75771,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 207 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -73744,23 +75783,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return node.parent.properties; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return node.parent.elements; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: { + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -73771,8 +75810,8 @@ var ts; } break; } - case 176 /* NewExpression */: - case 175 /* CallExpression */: { + case 179 /* NewExpression */: + case 178 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -73802,8 +75841,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 175 /* CallExpression */ || - node.parent.kind === 176 /* NewExpression */) && + if (node.parent && (node.parent.kind === 178 /* CallExpression */ || + node.parent.kind === 179 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -73821,10 +75860,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: node = node.expression; break; default: @@ -73888,48 +75927,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203 /* ExpressionStatement */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 171 /* ArrayLiteralExpression */: - case 200 /* Block */: - case 227 /* ModuleBlock */: - case 172 /* ObjectLiteralExpression */: - case 160 /* TypeLiteral */: - case 162 /* TupleType */: - case 228 /* CaseBlock */: - case 250 /* DefaultClause */: - case 249 /* CaseClause */: - case 179 /* ParenthesizedExpression */: - case 173 /* PropertyAccessExpression */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 201 /* VariableStatement */: - case 219 /* VariableDeclaration */: - case 236 /* ExportAssignment */: - case 212 /* ReturnStatement */: - case 189 /* ConditionalExpression */: - case 169 /* ArrayBindingPattern */: - case 168 /* ObjectBindingPattern */: - case 244 /* JsxOpeningElement */: - case 243 /* JsxSelfClosingElement */: - case 248 /* JsxExpression */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 143 /* Parameter */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 165 /* ParenthesizedType */: - case 177 /* TaggedTemplateExpression */: - case 185 /* AwaitExpression */: - case 238 /* NamedExports */: - case 234 /* NamedImports */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: + case 206 /* ExpressionStatement */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 174 /* ArrayLiteralExpression */: + case 203 /* Block */: + case 230 /* ModuleBlock */: + case 175 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 163 /* TupleType */: + case 231 /* CaseBlock */: + case 253 /* DefaultClause */: + case 252 /* CaseClause */: + case 182 /* ParenthesizedExpression */: + case 176 /* PropertyAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 204 /* VariableStatement */: + case 222 /* VariableDeclaration */: + case 239 /* ExportAssignment */: + case 215 /* ReturnStatement */: + case 192 /* ConditionalExpression */: + case 172 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 247 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 251 /* JsxExpression */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 144 /* Parameter */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 166 /* ParenthesizedType */: + case 180 /* TaggedTemplateExpression */: + case 188 /* AwaitExpression */: + case 241 /* NamedExports */: + case 237 /* NamedImports */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: return true; } return false; @@ -73938,27 +75977,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 207 /* ForStatement */: - case 204 /* IfStatement */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 181 /* ArrowFunction */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - return childKind !== 200 /* Block */; - case 237 /* ExportDeclaration */: - return childKind !== 238 /* NamedExports */; - case 231 /* ImportDeclaration */: - return childKind !== 232 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); - case 242 /* JsxElement */: - return childKind !== 245 /* JsxClosingElement */; + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 210 /* ForStatement */: + case 207 /* IfStatement */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 184 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return childKind !== 203 /* Block */; + case 240 /* ExportDeclaration */: + return childKind !== 241 /* NamedExports */; + case 234 /* ImportDeclaration */: + return childKind !== 235 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 237 /* NamedImports */); + case 245 /* JsxElement */: + return childKind !== 248 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -74048,7 +76087,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 178 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -74072,7 +76111,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -74117,7 +76156,7 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -74175,11 +76214,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(290 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -74194,11 +76233,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 140 /* FirstNode */) { + if (this.kind >= 141 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 273 /* FirstJSDocTagNode */ && this.kind <= 285 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 277 /* FirstJSDocTagNode */ && this.kind <= 289 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -74256,7 +76295,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -74264,7 +76303,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -74467,9 +76506,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 141 /* ComputedPropertyName */) { + if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 176 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -74489,10 +76528,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -74512,32 +76551,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 160 /* TypeLiteral */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 161 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 143 /* Parameter */: + case 144 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: { + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -74546,19 +76585,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 259 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: addDeclaration(node); break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -74570,7 +76609,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 236 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -74725,7 +76764,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 5 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -75100,10 +77139,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: case 98 /* ThisKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -75246,15 +77285,15 @@ var ts; return; } switch (node.kind) { - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -75271,7 +77310,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 === 226 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 229 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -75655,7 +77694,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 241 /* ExternalModuleReference */ || + node.parent.kind === 244 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -75675,7 +77714,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 /* ElementAccessExpression */ && + node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -75759,113 +77798,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219 /* VariableDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 222 /* VariableDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return spanInVariableDeclaration(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 200 /* Block */: + case 203 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return spanInBlock(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return spanInBlock(node.block); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 205 /* DoStatement */: + case 208 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 204 /* IfStatement */: + case 207 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return spanInForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 217 /* TryStatement */: + case 220 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 170 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 173 /* BindingElement */: // span on complete node return textSpan(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 144 /* Decorator */: + case 145 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -75895,7 +77934,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 139 /* OfKeyword */: + case 140 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -75908,13 +77947,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 === 70 /* Identifier */ || - node.kind == 192 /* SpreadElementExpression */ || - node.kind === 253 /* PropertyAssignment */ || - node.kind === 254 /* ShorthandPropertyAssignment */) && + node.kind == 195 /* SpreadElement */ || + node.kind === 256 /* PropertyAssignment */ || + node.kind === 257 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188 /* BinaryExpression */) { + if (node.kind === 191 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -75937,22 +77976,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205 /* DoStatement */: + case 208 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 144 /* Decorator */: + case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 212 /* ForOfStatement */: return textSpan(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -75961,13 +78000,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 253 /* PropertyAssignment */ && + if (node.parent.kind === 256 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 181 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -75975,8 +78014,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 219 /* VariableDeclaration */ || - node.parent.kind === 143 /* Parameter */)) { + if ((node.parent.kind === 222 /* VariableDeclaration */ || + node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -75984,7 +78023,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188 /* BinaryExpression */) { + if (node.parent.kind === 191 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -76010,7 +78049,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 211 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -76021,7 +78060,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 212 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -76061,7 +78100,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); + (functionDeclaration.parent.kind === 225 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -76084,25 +78123,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 206 /* WhileStatement */: - case 204 /* IfStatement */: - case 208 /* ForInStatement */: + case 209 /* WhileStatement */: + case 207 /* IfStatement */: + case 211 /* 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 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 212 /* 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 === 220 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 223 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -76127,23 +78166,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 197 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 170 /* BindingElement */) { + if (bindingPattern.parent.kind === 173 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); - var elements = node.kind === 171 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 172 /* ArrayBindingPattern */ && node.kind !== 171 /* ObjectBindingPattern */); + var elements = node.kind === 174 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 197 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -76151,18 +78190,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 === 188 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 191 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -76170,24 +78209,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 225 /* EnumDeclaration */: - case 222 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 200 /* Block */: + case 203 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 252 /* CatchClause */: + case 255 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -76195,7 +78234,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168 /* ObjectBindingPattern */: + case 171 /* 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); @@ -76211,7 +78250,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169 /* ArrayBindingPattern */: + case 172 /* 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); @@ -76226,12 +78265,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 /* DoStatement */ || - node.parent.kind === 175 /* CallExpression */ || - node.parent.kind === 176 /* NewExpression */) { + if (node.parent.kind === 208 /* DoStatement */ || + node.parent.kind === 178 /* CallExpression */ || + node.parent.kind === 179 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 179 /* ParenthesizedExpression */) { + if (node.parent.kind === 182 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -76240,21 +78279,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 179 /* ParenthesizedExpression */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: + case 210 /* ForStatement */: + case 212 /* ForOfStatement */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 182 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -76264,20 +78303,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 143 /* Parameter */) { + node.parent.kind === 256 /* PropertyAssignment */ || + node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178 /* TypeAssertionExpression */) { + if (node.parent.kind === 181 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205 /* DoStatement */) { + if (node.parent.kind === 208 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -76285,7 +78324,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.kind === 212 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -76367,7 +78406,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e8bb08ee96c..94a710ae867 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -163,170 +163,176 @@ declare namespace ts { DeclareKeyword = 123, GetKeyword = 124, IsKeyword = 125, - ModuleKeyword = 126, - NamespaceKeyword = 127, - NeverKeyword = 128, - ReadonlyKeyword = 129, - RequireKeyword = 130, - NumberKeyword = 131, - SetKeyword = 132, - StringKeyword = 133, - SymbolKeyword = 134, - TypeKeyword = 135, - UndefinedKeyword = 136, - FromKeyword = 137, - GlobalKeyword = 138, - OfKeyword = 139, - QualifiedName = 140, - ComputedPropertyName = 141, - TypeParameter = 142, - Parameter = 143, - Decorator = 144, - PropertySignature = 145, - PropertyDeclaration = 146, - MethodSignature = 147, - MethodDeclaration = 148, - Constructor = 149, - GetAccessor = 150, - SetAccessor = 151, - CallSignature = 152, - ConstructSignature = 153, - IndexSignature = 154, - TypePredicate = 155, - TypeReference = 156, - FunctionType = 157, - ConstructorType = 158, - TypeQuery = 159, - TypeLiteral = 160, - ArrayType = 161, - TupleType = 162, - UnionType = 163, - IntersectionType = 164, - ParenthesizedType = 165, - ThisType = 166, - LiteralType = 167, - ObjectBindingPattern = 168, - ArrayBindingPattern = 169, - BindingElement = 170, - ArrayLiteralExpression = 171, - ObjectLiteralExpression = 172, - PropertyAccessExpression = 173, - ElementAccessExpression = 174, - CallExpression = 175, - NewExpression = 176, - TaggedTemplateExpression = 177, - TypeAssertionExpression = 178, - ParenthesizedExpression = 179, - FunctionExpression = 180, - ArrowFunction = 181, - DeleteExpression = 182, - TypeOfExpression = 183, - VoidExpression = 184, - AwaitExpression = 185, - PrefixUnaryExpression = 186, - PostfixUnaryExpression = 187, - BinaryExpression = 188, - ConditionalExpression = 189, - TemplateExpression = 190, - YieldExpression = 191, - SpreadElementExpression = 192, - ClassExpression = 193, - OmittedExpression = 194, - ExpressionWithTypeArguments = 195, - AsExpression = 196, - NonNullExpression = 197, - TemplateSpan = 198, - SemicolonClassElement = 199, - Block = 200, - VariableStatement = 201, - EmptyStatement = 202, - ExpressionStatement = 203, - IfStatement = 204, - DoStatement = 205, - WhileStatement = 206, - ForStatement = 207, - ForInStatement = 208, - ForOfStatement = 209, - ContinueStatement = 210, - BreakStatement = 211, - ReturnStatement = 212, - WithStatement = 213, - SwitchStatement = 214, - LabeledStatement = 215, - ThrowStatement = 216, - TryStatement = 217, - DebuggerStatement = 218, - VariableDeclaration = 219, - VariableDeclarationList = 220, - FunctionDeclaration = 221, - ClassDeclaration = 222, - InterfaceDeclaration = 223, - TypeAliasDeclaration = 224, - EnumDeclaration = 225, - ModuleDeclaration = 226, - ModuleBlock = 227, - CaseBlock = 228, - NamespaceExportDeclaration = 229, - ImportEqualsDeclaration = 230, - ImportDeclaration = 231, - ImportClause = 232, - NamespaceImport = 233, - NamedImports = 234, - ImportSpecifier = 235, - ExportAssignment = 236, - ExportDeclaration = 237, - NamedExports = 238, - ExportSpecifier = 239, - MissingDeclaration = 240, - ExternalModuleReference = 241, - JsxElement = 242, - JsxSelfClosingElement = 243, - JsxOpeningElement = 244, - JsxClosingElement = 245, - JsxAttribute = 246, - JsxSpreadAttribute = 247, - JsxExpression = 248, - CaseClause = 249, - DefaultClause = 250, - HeritageClause = 251, - CatchClause = 252, - PropertyAssignment = 253, - ShorthandPropertyAssignment = 254, - EnumMember = 255, - SourceFile = 256, - JSDocTypeExpression = 257, - JSDocAllType = 258, - JSDocUnknownType = 259, - JSDocArrayType = 260, - JSDocUnionType = 261, - JSDocTupleType = 262, - JSDocNullableType = 263, - JSDocNonNullableType = 264, - JSDocRecordType = 265, - JSDocRecordMember = 266, - JSDocTypeReference = 267, - JSDocOptionalType = 268, - JSDocFunctionType = 269, - JSDocVariadicType = 270, - JSDocConstructorType = 271, - JSDocThisType = 272, - JSDocComment = 273, - JSDocTag = 274, - JSDocParameterTag = 275, - JSDocReturnTag = 276, - JSDocTypeTag = 277, - JSDocTemplateTag = 278, - JSDocTypedefTag = 279, - JSDocPropertyTag = 280, - JSDocTypeLiteral = 281, - JSDocLiteralType = 282, - JSDocNullKeyword = 283, - JSDocUndefinedKeyword = 284, - JSDocNeverKeyword = 285, - SyntaxList = 286, - NotEmittedStatement = 287, - PartiallyEmittedExpression = 288, - Count = 289, + KeyOfKeyword = 126, + ModuleKeyword = 127, + NamespaceKeyword = 128, + NeverKeyword = 129, + ReadonlyKeyword = 130, + RequireKeyword = 131, + NumberKeyword = 132, + SetKeyword = 133, + StringKeyword = 134, + SymbolKeyword = 135, + TypeKeyword = 136, + UndefinedKeyword = 137, + FromKeyword = 138, + GlobalKeyword = 139, + OfKeyword = 140, + QualifiedName = 141, + ComputedPropertyName = 142, + TypeParameter = 143, + Parameter = 144, + Decorator = 145, + PropertySignature = 146, + PropertyDeclaration = 147, + MethodSignature = 148, + MethodDeclaration = 149, + Constructor = 150, + GetAccessor = 151, + SetAccessor = 152, + CallSignature = 153, + ConstructSignature = 154, + IndexSignature = 155, + TypePredicate = 156, + TypeReference = 157, + FunctionType = 158, + ConstructorType = 159, + TypeQuery = 160, + TypeLiteral = 161, + ArrayType = 162, + TupleType = 163, + UnionType = 164, + IntersectionType = 165, + ParenthesizedType = 166, + ThisType = 167, + TypeOperator = 168, + IndexedAccessType = 169, + LiteralType = 170, + ObjectBindingPattern = 171, + ArrayBindingPattern = 172, + BindingElement = 173, + ArrayLiteralExpression = 174, + ObjectLiteralExpression = 175, + PropertyAccessExpression = 176, + ElementAccessExpression = 177, + CallExpression = 178, + NewExpression = 179, + TaggedTemplateExpression = 180, + TypeAssertionExpression = 181, + ParenthesizedExpression = 182, + FunctionExpression = 183, + ArrowFunction = 184, + DeleteExpression = 185, + TypeOfExpression = 186, + VoidExpression = 187, + AwaitExpression = 188, + PrefixUnaryExpression = 189, + PostfixUnaryExpression = 190, + BinaryExpression = 191, + ConditionalExpression = 192, + TemplateExpression = 193, + YieldExpression = 194, + SpreadElement = 195, + ClassExpression = 196, + OmittedExpression = 197, + ExpressionWithTypeArguments = 198, + AsExpression = 199, + NonNullExpression = 200, + TemplateSpan = 201, + SemicolonClassElement = 202, + Block = 203, + VariableStatement = 204, + EmptyStatement = 205, + ExpressionStatement = 206, + IfStatement = 207, + DoStatement = 208, + WhileStatement = 209, + ForStatement = 210, + ForInStatement = 211, + ForOfStatement = 212, + ContinueStatement = 213, + BreakStatement = 214, + ReturnStatement = 215, + WithStatement = 216, + SwitchStatement = 217, + LabeledStatement = 218, + ThrowStatement = 219, + TryStatement = 220, + DebuggerStatement = 221, + VariableDeclaration = 222, + VariableDeclarationList = 223, + FunctionDeclaration = 224, + ClassDeclaration = 225, + InterfaceDeclaration = 226, + TypeAliasDeclaration = 227, + EnumDeclaration = 228, + ModuleDeclaration = 229, + ModuleBlock = 230, + CaseBlock = 231, + NamespaceExportDeclaration = 232, + ImportEqualsDeclaration = 233, + ImportDeclaration = 234, + ImportClause = 235, + NamespaceImport = 236, + NamedImports = 237, + ImportSpecifier = 238, + ExportAssignment = 239, + ExportDeclaration = 240, + NamedExports = 241, + ExportSpecifier = 242, + MissingDeclaration = 243, + ExternalModuleReference = 244, + JsxElement = 245, + JsxSelfClosingElement = 246, + JsxOpeningElement = 247, + JsxClosingElement = 248, + JsxAttribute = 249, + JsxSpreadAttribute = 250, + JsxExpression = 251, + CaseClause = 252, + DefaultClause = 253, + HeritageClause = 254, + CatchClause = 255, + PropertyAssignment = 256, + ShorthandPropertyAssignment = 257, + SpreadAssignment = 258, + EnumMember = 259, + SourceFile = 260, + JSDocTypeExpression = 261, + JSDocAllType = 262, + JSDocUnknownType = 263, + JSDocArrayType = 264, + JSDocUnionType = 265, + JSDocTupleType = 266, + JSDocNullableType = 267, + JSDocNonNullableType = 268, + JSDocRecordType = 269, + JSDocRecordMember = 270, + JSDocTypeReference = 271, + JSDocOptionalType = 272, + JSDocFunctionType = 273, + JSDocVariadicType = 274, + JSDocConstructorType = 275, + JSDocThisType = 276, + JSDocComment = 277, + JSDocTag = 278, + JSDocParameterTag = 279, + JSDocReturnTag = 280, + JSDocTypeTag = 281, + JSDocTemplateTag = 282, + JSDocTypedefTag = 283, + JSDocPropertyTag = 284, + JSDocTypeLiteral = 285, + JSDocLiteralType = 286, + JSDocNullKeyword = 287, + JSDocUndefinedKeyword = 288, + JSDocNeverKeyword = 289, + SyntaxList = 290, + NotEmittedStatement = 291, + PartiallyEmittedExpression = 292, + MergeDeclarationMarker = 293, + EndOfDeclarationMarker = 294, + Count = 295, FirstAssignment = 57, LastAssignment = 69, FirstCompoundAssignment = 58, @@ -334,15 +340,15 @@ declare namespace ts { FirstReservedWord = 71, LastReservedWord = 106, FirstKeyword = 71, - LastKeyword = 139, + LastKeyword = 140, FirstFutureReservedWord = 107, LastFutureReservedWord = 115, - FirstTypeNode = 155, - LastTypeNode = 167, + FirstTypeNode = 156, + LastTypeNode = 170, FirstPunctuation = 16, LastPunctuation = 69, FirstToken = 0, - LastToken = 139, + LastToken = 140, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -351,11 +357,11 @@ declare namespace ts { LastTemplateToken = 15, FirstBinaryOperator = 26, LastBinaryOperator = 69, - FirstNode = 140, - FirstJSDocNode = 257, - LastJSDocNode = 282, - FirstJSDocTagNode = 273, - LastJSDocTagNode = 285, + FirstNode = 141, + FirstJSDocNode = 261, + LastJSDocNode = 286, + FirstJSDocTagNode = 277, + LastJSDocTagNode = 289, } enum NodeFlags { None = 0, @@ -373,21 +379,22 @@ declare namespace ts { HasDecorators = 2048, HasParamDecorators = 4096, HasAsyncFunctions = 8192, - HasJsxSpreadAttributes = 16384, - DisallowInContext = 32768, - YieldContext = 65536, - DecoratorContext = 131072, - AwaitContext = 262144, - ThisNodeHasError = 524288, - JavaScriptFile = 1048576, - ThisNodeOrAnySubNodesHasError = 2097152, - HasAggregatedChildData = 4194304, + HasSpreadAttribute = 16384, + HasRestAttribute = 32768, + DisallowInContext = 65536, + YieldContext = 131072, + DecoratorContext = 262144, + AwaitContext = 524288, + ThisNodeHasError = 1048576, + JavaScriptFile = 2097152, + ThisNodeOrAnySubNodesHasError = 4194304, + HasAggregatedChildData = 8388608, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 31744, - ReachabilityAndEmitFlags = 32128, - ContextFlags = 1540096, - TypeExcludesFlags = 327680, + EmitHelperFlags = 64512, + ReachabilityAndEmitFlags = 64896, + ContextFlags = 3080192, + TypeExcludesFlags = 655360, } enum ModifierFlags { None = 0, @@ -407,6 +414,7 @@ declare namespace ts { ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, + ExportDefault = 513, } enum JsxFlags { None = 0, @@ -534,7 +542,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -548,6 +556,10 @@ declare namespace ts { equalsToken?: Token; objectAssignmentInitializer?: Expression; } + interface SpreadAssignment extends ObjectLiteralElement { + kind: SyntaxKind.SpreadAssignment; + expression: Expression; + } interface VariableLikeDeclaration extends Declaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; @@ -678,6 +690,16 @@ declare namespace ts { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } + interface TypeOperatorNode extends TypeNode { + kind: SyntaxKind.TypeOperator; + operator: SyntaxKind.KeyOfKeyword; + type: TypeNode; + } + interface IndexedAccessTypeNode extends TypeNode { + kind: SyntaxKind.IndexedAccessType; + objectType: TypeNode; + indexType: TypeNode; + } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: Expression; @@ -710,9 +732,6 @@ declare namespace ts { operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } - interface PostfixExpression extends UnaryExpression { - _postfixExpressionBrand: any; - } interface LeftHandSideExpression extends IncrementExpression { _leftHandSideExpressionBrand: any; } @@ -781,6 +800,17 @@ declare namespace ts { operatorToken: BinaryOperatorToken; right: Expression; } + interface AssignmentExpression extends BinaryExpression { + left: LeftHandSideExpression; + operatorToken: Token; + } + interface ObjectDestructuringAssignment extends AssignmentExpression { + left: ObjectLiteralExpression; + } + interface ArrayDestructuringAssignment extends AssignmentExpression { + left: ArrayLiteralExpression; + } + type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; @@ -847,8 +877,8 @@ declare namespace ts { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray; } - interface SpreadElementExpression extends Expression { - kind: SyntaxKind.SpreadElementExpression; + interface SpreadElement extends Expression { + kind: SyntaxKind.SpreadElement; expression: Expression; } /** @@ -1717,6 +1747,8 @@ declare namespace ts { Object = 32768, Union = 65536, Intersection = 131072, + Index = 262144, + IndexedAccess = 524288, Literal = 480, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, @@ -1726,8 +1758,8 @@ declare namespace ts { EnumLike = 272, UnionOrIntersection = 196608, StructuredType = 229376, - StructuredOrTypeParameter = 245760, - Narrowable = 246783, + StructuredOrTypeParameter = 507904, + Narrowable = 1033215, NotUnionOrUnit = 33281, } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -1798,6 +1830,13 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } + interface IndexType extends Type { + type: TypeParameter; + } + interface IndexedAccessType extends Type { + objectType: Type; + indexType: TypeParameter; + } enum SignatureKind { Call = 0, Construct = 1, @@ -1899,6 +1938,7 @@ declare namespace ts { preserveConstEnums?: boolean; project?: string; reactNamespace?: string; + jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; @@ -1965,12 +2005,14 @@ declare namespace ts { ES2015 = 2, ES2016 = 3, ES2017 = 4, - Latest = 4, + ESNext = 5, + Latest = 5, } enum LanguageVariant { Standard = 0, JSX = 1, } + /** Either a parsed command line or a parsed tsconfig.json */ interface ParsedCommandLine { options: CompilerOptions; typingOptions?: TypingOptions; @@ -1997,12 +2039,45 @@ declare namespace ts { getCurrentDirectory?(): string; getDirectories?(path: string): string[]; } + /** + * Represents the result of module resolution. + * Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off. + * The Program will then filter results based on these flags. + * + * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. + */ interface ResolvedModule { + /** Path of the file the module was resolved to. */ resolvedFileName: string; + /** + * Denotes if 'resolvedFileName' is isExternalLibraryImport and thus should be a proper external module: + * - be a .d.ts file + * - use top level imports\exports + * - don't use tripleslash references + */ isExternalLibraryImport?: boolean; } + /** + * ResolvedModule with an explicitly provided `extension` property. + * Prefer this over `ResolvedModule`. + */ + interface ResolvedModuleFull extends ResolvedModule { + /** + * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. + * This is optional for backwards-compatibility, but will be added if not provided. + */ + extension: Extension; + } + enum Extension { + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, + } interface ResolvedModuleWithFailedLookupLocations { - resolvedModule: ResolvedModule; + resolvedModule: ResolvedModuleFull | undefined; failedLookupLocations: string[]; } interface ResolvedTypeReferenceDirective { @@ -2060,7 +2135,11 @@ declare namespace ts { readFile(path: string, encoding?: string): string; getFileSize?(path: string): number; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; - watchFile?(path: string, callback: FileWatcherCallback): FileWatcher; + /** + * @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that + * use native OS file watching + */ + watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher; resolvePath(path: string): string; fileExists(path: string): boolean; @@ -2179,6 +2258,7 @@ declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } @@ -2192,7 +2272,7 @@ declare namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -2208,7 +2288,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.2"; + const version = "2.1.3"; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index fd0da3fb87f..23bd3d859c1 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -22,6 +22,7 @@ var ts; (function (ts) { // token > SyntaxKind.Identifer => token is a keyword // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync + var SyntaxKind; (function (SyntaxKind) { SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; @@ -160,191 +161,197 @@ var ts; SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 126] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 127] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 128] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 129] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 130] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 131] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 132] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 133] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 134] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 135] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 136] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 137] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 138] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 139] = "OfKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 133] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 134] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 135] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 136] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 137] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 138] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 139] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 140] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 140] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 141] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 141] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 142] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 142] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 143] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 144] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 143] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 144] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 145] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 145] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 146] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 147] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 148] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 149] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 150] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 151] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 152] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 153] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 154] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 147] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 148] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 149] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 150] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 151] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 152] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 153] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 154] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 155] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 155] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 156] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 157] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 158] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 159] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 160] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 161] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 162] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 163] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 164] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 165] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 166] = "ThisType"; - SyntaxKind[SyntaxKind["LiteralType"] = 167] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 156] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 157] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 158] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 159] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 160] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 161] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 162] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 163] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 164] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 165] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 166] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 167] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 168] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 169] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["LiteralType"] = 170] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 168] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 169] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 170] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 171] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 172] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 173] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 171] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 172] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 173] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 174] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 175] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 176] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 177] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 178] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 179] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 180] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 181] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 182] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 183] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 184] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 185] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 186] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 187] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 188] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 189] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 190] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 191] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 192] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 193] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 194] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 195] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 196] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 197] = "NonNullExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 174] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 175] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 176] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 177] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 178] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 179] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 180] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 181] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 182] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 183] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 184] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 185] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 186] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 187] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 188] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 189] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 190] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 191] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 192] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 193] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 194] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 195] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 196] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 197] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 198] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 199] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 200] = "NonNullExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 198] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 199] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 201] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 202] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 200] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 201] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 202] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 203] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 204] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 205] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 206] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 207] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 208] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 209] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 210] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 211] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 212] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 213] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 214] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 215] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 216] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 217] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 218] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 219] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 220] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 221] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 222] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 223] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 224] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 225] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 226] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 227] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 228] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 229] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 230] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 231] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 232] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 233] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 234] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 235] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 236] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 237] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 238] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 239] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 240] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 203] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 204] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 205] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 206] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 207] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 208] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 209] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 210] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 211] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 212] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 213] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 214] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 215] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 216] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 217] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 218] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 219] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 220] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 221] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 222] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 223] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 224] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 225] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 226] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 227] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 228] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 229] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 230] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 231] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 232] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 233] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 234] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 235] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 236] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 237] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 238] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 239] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 240] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 241] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 242] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 243] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 241] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 244] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 242] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 243] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 244] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 245] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 246] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 247] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 248] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 245] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 246] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 247] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 248] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 249] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 250] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 251] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 249] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 250] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 251] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 252] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 252] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 253] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 254] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 255] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 253] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 254] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 256] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 257] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 258] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 255] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 259] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 256] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 260] = "SourceFile"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 257] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 261] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 258] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 262] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 259] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 260] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 261] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 262] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 263] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 264] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 265] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 266] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 267] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 268] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 269] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 270] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 271] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 272] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 273] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 274] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 275] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 276] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 277] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 278] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 279] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 280] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 281] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 282] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 283] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 284] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 285] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 263] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 264] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 265] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 266] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 267] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 268] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 269] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 270] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 271] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 272] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 273] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 274] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 275] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 276] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 277] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 278] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 279] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 280] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 281] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 282] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 283] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 284] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 285] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 286] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 287] = "JSDocNullKeyword"; + SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 288] = "JSDocUndefinedKeyword"; + SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 289] = "JSDocNeverKeyword"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 286] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 290] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 287] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 288] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 291] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 292] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 293] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 294] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 289] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 295] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; @@ -353,15 +360,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 139] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 140] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 155] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 167] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 156] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 170] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 139] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 140] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -370,13 +377,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 140] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 257] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 282] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 273] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 285] = "LastJSDocTagNode"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; + SyntaxKind[SyntaxKind["FirstNode"] = 141] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 261] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 286] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 277] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 289] = "LastJSDocTagNode"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; NodeFlags[NodeFlags["Let"] = 1] = "Let"; @@ -393,25 +400,26 @@ var ts; NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["HasJsxSpreadAttributes"] = 16384] = "HasJsxSpreadAttributes"; - NodeFlags[NodeFlags["DisallowInContext"] = 32768] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 65536] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 131072] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 262144] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 524288] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 1048576] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 2097152] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 4194304] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["HasSpreadAttribute"] = 16384] = "HasSpreadAttribute"; + NodeFlags[NodeFlags["HasRestAttribute"] = 32768] = "HasRestAttribute"; + NodeFlags[NodeFlags["DisallowInContext"] = 65536] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 131072] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 262144] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 524288] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 1048576] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 2097152] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 4194304] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 8388608] = "HasAggregatedChildData"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 31744] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 32128] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["EmitHelperFlags"] = 64512] = "EmitHelperFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 64896] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 1540096] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 3080192] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 327680] = "TypeExcludesFlags"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 655360] = "TypeExcludesFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; (function (ModifierFlags) { ModifierFlags[ModifierFlags["None"] = 0] = "None"; ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; @@ -431,8 +439,9 @@ var ts; ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; - })(ts.ModifierFlags || (ts.ModifierFlags = {})); - var ModifierFlags = ts.ModifierFlags; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; (function (JsxFlags) { JsxFlags[JsxFlags["None"] = 0] = "None"; /** An element from a named property of the JSX.IntrinsicElements interface */ @@ -440,24 +449,24 @@ var ts; /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; - })(ts.JsxFlags || (ts.JsxFlags = {})); - var JsxFlags = ts.JsxFlags; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); /* @internal */ + var RelationComparisonResult; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; - })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); - var RelationComparisonResult = ts.RelationComparisonResult; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ + var GeneratedIdentifierKind; (function (GeneratedIdentifierKind) { GeneratedIdentifierKind[GeneratedIdentifierKind["None"] = 0] = "None"; GeneratedIdentifierKind[GeneratedIdentifierKind["Auto"] = 1] = "Auto"; GeneratedIdentifierKind[GeneratedIdentifierKind["Loop"] = 2] = "Loop"; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; - })(ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); - var GeneratedIdentifierKind = ts.GeneratedIdentifierKind; + })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; FlowFlags[FlowFlags["Start"] = 2] = "Start"; @@ -472,8 +481,7 @@ var ts; FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; - })(ts.FlowFlags || (ts.FlowFlags = {})); - var FlowFlags = ts.FlowFlags; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); var OperationCanceledException = (function () { function OperationCanceledException() { } @@ -481,6 +489,7 @@ var ts; }()); ts.OperationCanceledException = OperationCanceledException; /** Return code used by getEmitOutput function to indicate status of the function */ + var ExitStatus; (function (ExitStatus) { // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, // when -version or -help was provided, or this was a normal compilation, no diagnostics @@ -490,8 +499,8 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; // Diagnostics were produced and outputs were generated in spite of them. ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 1] = "WriteArrayAsGenericType"; @@ -505,8 +514,8 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 256] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 512] = "InTypeAlias"; TypeFormatFlags[TypeFormatFlags["UseTypeAliasValue"] = 1024] = "UseTypeAliasValue"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; (function (SymbolFormatFlags) { SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; // Write symbols's type argument if it is instantiated symbol @@ -518,23 +527,29 @@ var ts; // eg. module m { export class c { } } import x = m.c; // When this flag is specified m.c will be used to refer to the class instead of alias symbol x SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 2] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; + })(SymbolFormatFlags = ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); /* @internal */ + var SymbolAccessibility; (function (SymbolAccessibility) { SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; - })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); - var SymbolAccessibility = ts.SymbolAccessibility; + })(SymbolAccessibility = ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); + /* @internal */ + var SyntheticSymbolKind; + (function (SyntheticSymbolKind) { + SyntheticSymbolKind[SyntheticSymbolKind["UnionOrIntersection"] = 0] = "UnionOrIntersection"; + SyntheticSymbolKind[SyntheticSymbolKind["Spread"] = 1] = "Spread"; + })(SyntheticSymbolKind = ts.SyntheticSymbolKind || (ts.SyntheticSymbolKind = {})); + var TypePredicateKind; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; - })(ts.TypePredicateKind || (ts.TypePredicateKind = {})); - var TypePredicateKind = ts.TypePredicateKind; + })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator * metadata */ /* @internal */ + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; // should be emitted using a safe fallback. @@ -552,8 +567,8 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; // with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var SymbolFlags; (function (SymbolFlags) { SymbolFlags[SymbolFlags["None"] = 0] = "None"; SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; @@ -628,9 +643,9 @@ var ts; // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; + })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ + var NodeCheckFlags; (function (NodeCheckFlags) { NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 1] = "TypeChecked"; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; @@ -652,8 +667,8 @@ var ts; NodeCheckFlags[NodeCheckFlags["AssignmentsMarked"] = 4194304] = "AssignmentsMarked"; NodeCheckFlags[NodeCheckFlags["ClassWithConstructorReference"] = 8388608] = "ClassWithConstructorReference"; NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 16777216] = "ConstructorReferenceInClass"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; + })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); + var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; TypeFlags[TypeFlags["String"] = 2] = "String"; @@ -673,14 +688,16 @@ var ts; TypeFlags[TypeFlags["Object"] = 32768] = "Object"; TypeFlags[TypeFlags["Union"] = 65536] = "Union"; TypeFlags[TypeFlags["Intersection"] = 131072] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 262144] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 524288] = "IndexedAccess"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 262144] = "FreshLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 1048576] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsWideningType"] = 2097152] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 1048576] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 4194304] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 2097152] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 8388608] = "ContainsAnyFunctionType"; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 480] = "Literal"; @@ -698,17 +715,17 @@ var ts; TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection"; TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType"; - TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 245760] = "StructuredOrTypeParameter"; + TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 246783] = "Narrowable"; + TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable"; TypeFlags[TypeFlags["NotUnionOrUnit"] = 33281] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 6291456] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; + TypeFlags[TypeFlags["PropagatingFlags"] = 14680064] = "PropagatingFlags"; + })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); + var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface"; @@ -720,19 +737,19 @@ var ts; ObjectFlags[ObjectFlags["EvolvingArray"] = 128] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 256] = "ObjectLiteralPatternWithComputedProperties"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; - })(ts.ObjectFlags || (ts.ObjectFlags = {})); - var ObjectFlags = ts.ObjectFlags; + })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); + var SignatureKind; (function (SignatureKind) { SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; + })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; + })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); /* @internal */ + var SpecialPropertyAssignmentKind; (function (SpecialPropertyAssignmentKind) { SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["None"] = 0] = "None"; /// exports.name = expr @@ -743,19 +760,19 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; /// this.name = expr SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; - })(ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); - var SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind; + })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); + var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; + })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var ModuleResolutionKind; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; + })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -763,53 +780,54 @@ var ts; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; + })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var JsxEmit; (function (JsxEmit) { JsxEmit[JsxEmit["None"] = 0] = "None"; JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; JsxEmit[JsxEmit["React"] = 2] = "React"; - })(ts.JsxEmit || (ts.JsxEmit = {})); - var JsxEmit = ts.JsxEmit; + })(JsxEmit = ts.JsxEmit || (ts.JsxEmit = {})); + var NewLineKind; (function (NewLineKind) { NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; - })(ts.NewLineKind || (ts.NewLineKind = {})); - var NewLineKind = ts.NewLineKind; + })(NewLineKind = ts.NewLineKind || (ts.NewLineKind = {})); + var ScriptKind; (function (ScriptKind) { ScriptKind[ScriptKind["Unknown"] = 0] = "Unknown"; ScriptKind[ScriptKind["JS"] = 1] = "JS"; ScriptKind[ScriptKind["JSX"] = 2] = "JSX"; ScriptKind[ScriptKind["TS"] = 3] = "TS"; ScriptKind[ScriptKind["TSX"] = 4] = "TSX"; - })(ts.ScriptKind || (ts.ScriptKind = {})); - var ScriptKind = ts.ScriptKind; + })(ScriptKind = ts.ScriptKind || (ts.ScriptKind = {})); + var ScriptTarget; (function (ScriptTarget) { ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015"; ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016"; ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017"; - ScriptTarget[ScriptTarget["Latest"] = 4] = "Latest"; - })(ts.ScriptTarget || (ts.ScriptTarget = {})); - var ScriptTarget = ts.ScriptTarget; + ScriptTarget[ScriptTarget["ESNext"] = 5] = "ESNext"; + ScriptTarget[ScriptTarget["Latest"] = 5] = "Latest"; + })(ScriptTarget = ts.ScriptTarget || (ts.ScriptTarget = {})); + var LanguageVariant; (function (LanguageVariant) { LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; - })(ts.LanguageVariant || (ts.LanguageVariant = {})); - var LanguageVariant = ts.LanguageVariant; + })(LanguageVariant = ts.LanguageVariant || (ts.LanguageVariant = {})); /* @internal */ + var DiagnosticStyle; (function (DiagnosticStyle) { DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; - })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); - var DiagnosticStyle = ts.DiagnosticStyle; + })(DiagnosticStyle = ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var WatchDirectoryFlags; (function (WatchDirectoryFlags) { WatchDirectoryFlags[WatchDirectoryFlags["None"] = 0] = "None"; WatchDirectoryFlags[WatchDirectoryFlags["Recursive"] = 1] = "Recursive"; - })(ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); - var WatchDirectoryFlags = ts.WatchDirectoryFlags; + })(WatchDirectoryFlags = ts.WatchDirectoryFlags || (ts.WatchDirectoryFlags = {})); /* @internal */ + var CharacterCodes; (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -936,9 +954,18 @@ var ts; CharacterCodes[CharacterCodes["byteOrderMark"] = 65279] = "byteOrderMark"; CharacterCodes[CharacterCodes["tab"] = 9] = "tab"; CharacterCodes[CharacterCodes["verticalTab"] = 11] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; + })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ + var TransformFlags; (function (TransformFlags) { TransformFlags[TransformFlags["None"] = 0] = "None"; // Facts @@ -947,61 +974,66 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 2] = "ContainsTypeScript"; TransformFlags[TransformFlags["Jsx"] = 4] = "Jsx"; TransformFlags[TransformFlags["ContainsJsx"] = 8] = "ContainsJsx"; - TransformFlags[TransformFlags["ES2017"] = 16] = "ES2017"; - TransformFlags[TransformFlags["ContainsES2017"] = 32] = "ContainsES2017"; - TransformFlags[TransformFlags["ES2016"] = 64] = "ES2016"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ES2015"] = 256] = "ES2015"; - TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; - TransformFlags[TransformFlags["DestructuringAssignment"] = 1024] = "DestructuringAssignment"; - TransformFlags[TransformFlags["Generator"] = 2048] = "Generator"; - TransformFlags[TransformFlags["ContainsGenerator"] = 4096] = "ContainsGenerator"; + TransformFlags[TransformFlags["ESNext"] = 16] = "ESNext"; + TransformFlags[TransformFlags["ContainsESNext"] = 32] = "ContainsESNext"; + TransformFlags[TransformFlags["ES2017"] = 64] = "ES2017"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ES2016"] = 256] = "ES2016"; + TransformFlags[TransformFlags["ContainsES2016"] = 512] = "ContainsES2016"; + TransformFlags[TransformFlags["ES2015"] = 1024] = "ES2015"; + TransformFlags[TransformFlags["ContainsES2015"] = 2048] = "ContainsES2015"; + TransformFlags[TransformFlags["Generator"] = 4096] = "Generator"; + TransformFlags[TransformFlags["ContainsGenerator"] = 8192] = "ContainsGenerator"; + TransformFlags[TransformFlags["DestructuringAssignment"] = 16384] = "DestructuringAssignment"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 32768] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsDecorators"] = 8192] = "ContainsDecorators"; - TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 16384] = "ContainsPropertyInitializer"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 32768] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 65536] = "ContainsCapturedLexicalThis"; - TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 131072] = "ContainsLexicalThisInComputedPropertyName"; - TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 262144] = "ContainsDefaultValueAssignments"; - TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 524288] = "ContainsParameterPropertyAssignments"; - TransformFlags[TransformFlags["ContainsSpreadElementExpression"] = 1048576] = "ContainsSpreadElementExpression"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 2097152] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 4194304] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 8388608] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 16777216] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 33554432] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDecorators"] = 65536] = "ContainsDecorators"; + TransformFlags[TransformFlags["ContainsPropertyInitializer"] = 131072] = "ContainsPropertyInitializer"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 262144] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsCapturedLexicalThis"] = 524288] = "ContainsCapturedLexicalThis"; + TransformFlags[TransformFlags["ContainsLexicalThisInComputedPropertyName"] = 1048576] = "ContainsLexicalThisInComputedPropertyName"; + TransformFlags[TransformFlags["ContainsDefaultValueAssignments"] = 2097152] = "ContainsDefaultValueAssignments"; + TransformFlags[TransformFlags["ContainsParameterPropertyAssignments"] = 4194304] = "ContainsParameterPropertyAssignments"; + TransformFlags[TransformFlags["ContainsSpreadExpression"] = 8388608] = "ContainsSpreadExpression"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 16777216] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 33554432] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 67108864] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 134217728] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 268435456] = "ContainsHoistedDeclarationOrCompletion"; TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 3] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 12] = "AssertJsx"; - TransformFlags[TransformFlags["AssertES2017"] = 48] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 192] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 768] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 6144] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertESNext"] = 48] = "AssertESNext"; + TransformFlags[TransformFlags["AssertES2017"] = 192] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 768] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 3072] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 12288] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 49152] = "AssertDestructuringAssignment"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["NodeExcludes"] = 536874325] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 592227669] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 592293205] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 591760725] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 591760725] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 539749717] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 574729557] = "ModuleExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = 536892757] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 979719509] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 980243797] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 975983957] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 975983957] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 559895893] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 839734613] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -3] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 539110741] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 537922901] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 545262933] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 545262933] = "ParameterExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 554784085] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 545281365] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 604001621] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = 604001621] = "ParameterExcludes"; // Masks // - Additional bitmasks - TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 548864] = "TypeScriptClassSyntaxMask"; - TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 327680] = "ES2015FunctionSyntaxMask"; - })(ts.TransformFlags || (ts.TransformFlags = {})); - var TransformFlags = ts.TransformFlags; + TransformFlags[TransformFlags["TypeScriptClassSyntaxMask"] = 4390912] = "TypeScriptClassSyntaxMask"; + TransformFlags[TransformFlags["ES2015FunctionSyntaxMask"] = 2621440] = "ES2015FunctionSyntaxMask"; + })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); /* @internal */ + var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["EmitEmitHelpers"] = 1] = "EmitEmitHelpers"; EmitFlags[EmitFlags["EmitExportStar"] = 2] = "EmitExportStar"; @@ -1030,16 +1062,17 @@ var ts; EmitFlags[EmitFlags["AsyncFunctionBody"] = 2097152] = "AsyncFunctionBody"; EmitFlags[EmitFlags["ReuseTempVariableScope"] = 4194304] = "ReuseTempVariableScope"; EmitFlags[EmitFlags["CustomPrologue"] = 8388608] = "CustomPrologue"; - })(ts.EmitFlags || (ts.EmitFlags = {})); - var EmitFlags = ts.EmitFlags; + EmitFlags[EmitFlags["NoHoisting"] = 16777216] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 33554432] = "HasEndOfDeclarationMarker"; + })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /* @internal */ + var EmitContext; (function (EmitContext) { EmitContext[EmitContext["SourceFile"] = 0] = "SourceFile"; EmitContext[EmitContext["Expression"] = 1] = "Expression"; EmitContext[EmitContext["IdentifierName"] = 2] = "IdentifierName"; EmitContext[EmitContext["Unspecified"] = 3] = "Unspecified"; - })(ts.EmitContext || (ts.EmitContext = {})); - var EmitContext = ts.EmitContext; + })(EmitContext = ts.EmitContext || (ts.EmitContext = {})); })(ts || (ts = {})); /*@internal*/ var ts; @@ -1149,12 +1182,12 @@ var ts; * 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. */ + var Ternary; (function (Ternary) { Ternary[Ternary["False"] = 0] = "False"; Ternary[Ternary["Maybe"] = 1] = "Maybe"; Ternary[Ternary["True"] = -1] = "True"; - })(ts.Ternary || (ts.Ternary = {})); - var Ternary = ts.Ternary; + })(Ternary = ts.Ternary || (ts.Ternary = {})); var createObject = Object.create; // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -1226,12 +1259,12 @@ var ts; return getCanonicalFileName(nonCanonicalizedPath); } ts.toPath = toPath; + var Comparison; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; - })(ts.Comparison || (ts.Comparison = {})); - var Comparison = ts.Comparison; + })(Comparison = ts.Comparison || (ts.Comparison = {})); /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -1249,6 +1282,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; /** * Iterates through `array` by index and performs the callback on each element of array until the callback * returns a falsey value, then returns false. @@ -1541,20 +1581,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -1634,6 +1679,31 @@ var ts; return result || array; } ts.compact = compact; + /** + * Gets the relative complement of `arrayA` with respect to `b`, returning the elements that + * are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted + * based on the provided comparer. + */ + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1 /* LessThan */: break inner; + case 0 /* EqualTo */: continue outer; + case 1 /* GreaterThan */: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -1643,15 +1713,39 @@ var ts; return result; } ts.sum = sum; + /** + * Appends a value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param value The value to append to the array. If `value` is `undefined`, nothing is + * appended. + */ + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; + /** + * Appends a range of value to an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + */ function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -1664,26 +1758,17 @@ var ts; return true; } ts.rangeEquals = rangeEquals; + /** + * Returns the first element of an array if non-empty, `undefined` otherwise. + */ function firstOrUndefined(array) { return array && array.length > 0 ? array[0] : undefined; } ts.firstOrUndefined = firstOrUndefined; - function singleOrUndefined(array) { - return array && array.length === 1 - ? array[0] - : undefined; - } - ts.singleOrUndefined = singleOrUndefined; - function singleOrMany(array) { - return array && array.length === 1 - ? array[0] - : array; - } - ts.singleOrMany = singleOrMany; /** - * Returns the last element of an array if non-empty, undefined otherwise. + * Returns the last element of an array if non-empty, `undefined` otherwise. */ function lastOrUndefined(array) { return array && array.length > 0 @@ -1691,6 +1776,25 @@ var ts; : undefined; } ts.lastOrUndefined = lastOrUndefined; + /** + * Returns the only element of an array if it contains only one element, `undefined` otherwise. + */ + function singleOrUndefined(array) { + return array && array.length === 1 + ? array[0] + : undefined; + } + ts.singleOrUndefined = singleOrUndefined; + /** + * Returns the only element of an array if it contains only one element; otheriwse, returns the + * array. + */ + function singleOrMany(array) { + return array && array.length === 1 + ? array[0] + : array; + } + ts.singleOrMany = singleOrMany; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; @@ -1704,11 +1808,11 @@ var ts; * @param array A sorted array whose first element must be no larger than number * @param number The value to be searched for in the array. */ - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -2606,6 +2710,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -2646,73 +2754,93 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - // getNormalizedPathComponents includes the separator for the root component. - // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - // The * and ? wildcards should not match directories or files that start with . if they - // appear first in a component. Dotted directories and files can be included explicitly - // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63 /* question */) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + // If excluding, match "foo/bar/baz...", but if including, only allow "foo". + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + /** + * An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, + * and does not contain any glob characters itself. + */ + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + // getNormalizedPathComponents includes the separator for the root component. + // We need to remove to create our regex correctly. + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + // The * and ? wildcards should not match directories or files that start with . if they + // appear first in a component. Dotted directories and files can be included explicitly + // like so: **/.*/.* + if (component.charCodeAt(0) === 42 /* asterisk */) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63 /* question */) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -2786,29 +2914,35 @@ var ts; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); // Append the literal and canonical candidate base paths. - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); + } + }; // Iterate over each include base path and include unique base paths that are not a // subpath of an existing base path - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } - } - basePaths.push(includeBasePath); + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + // No "*" or "?" in the path + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { // Using scriptKind as a condition handles both: // - 'scriptKind' is unspecified and thus it is `undefined` @@ -2873,14 +3007,14 @@ var ts; * aligned to the offset of the highest priority extension in the * allSupportedExtensions array. */ + var ExtensionPriority; (function (ExtensionPriority) { ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; ExtensionPriority[ExtensionPriority["Limit"] = 5] = "Limit"; ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; - })(ts.ExtensionPriority || (ts.ExtensionPriority = {})); - var ExtensionPriority = ts.ExtensionPriority; + })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); function getExtensionPriority(path, supportedExtensions) { for (var i = supportedExtensions.length - 1; i >= 0; i--) { if (fileExtensionIs(path, supportedExtensions[i])) { @@ -2939,10 +3073,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -2977,13 +3107,13 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; + var AssertionLevel; (function (AssertionLevel) { AssertionLevel[AssertionLevel["None"] = 0] = "None"; AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(ts.AssertionLevel || (ts.AssertionLevel = {})); - var AssertionLevel = ts.AssertionLevel; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); var Debug; (function (Debug) { Debug.currentAssertionLevel = 0 /* None */; @@ -3120,6 +3250,35 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + /** True if an extension is one of the supported TypeScript extensions. */ + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + /** + * Gets the extension from a path. + * Path must have a valid extension. + */ + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); /// var ts; @@ -3441,6 +3600,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1 /* Directory */); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -3450,7 +3610,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -3458,7 +3618,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -3475,7 +3635,7 @@ var ts; // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -3684,7 +3844,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -3911,14 +4071,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -3958,7 +4118,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -3996,8 +4156,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -4009,7 +4167,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -4031,9 +4189,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -4080,6 +4236,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -4103,6 +4266,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -4134,6 +4298,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -4233,6 +4400,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -4316,7 +4484,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -4353,11 +4521,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -4366,7 +4539,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -4423,6 +4597,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); /// @@ -4458,7 +4633,7 @@ var ts; "false": 85 /* FalseKeyword */, "finally": 86 /* FinallyKeyword */, "for": 87 /* ForKeyword */, - "from": 137 /* FromKeyword */, + "from": 138 /* FromKeyword */, "function": 88 /* FunctionKeyword */, "get": 124 /* GetKeyword */, "if": 89 /* IfKeyword */, @@ -4468,34 +4643,35 @@ var ts; "instanceof": 92 /* InstanceOfKeyword */, "interface": 108 /* InterfaceKeyword */, "is": 125 /* IsKeyword */, + "keyof": 126 /* KeyOfKeyword */, "let": 109 /* LetKeyword */, - "module": 126 /* ModuleKeyword */, - "namespace": 127 /* NamespaceKeyword */, - "never": 128 /* NeverKeyword */, + "module": 127 /* ModuleKeyword */, + "namespace": 128 /* NamespaceKeyword */, + "never": 129 /* NeverKeyword */, "new": 93 /* NewKeyword */, "null": 94 /* NullKeyword */, - "number": 131 /* NumberKeyword */, + "number": 132 /* NumberKeyword */, "package": 110 /* PackageKeyword */, "private": 111 /* PrivateKeyword */, "protected": 112 /* ProtectedKeyword */, "public": 113 /* PublicKeyword */, - "readonly": 129 /* ReadonlyKeyword */, - "require": 130 /* RequireKeyword */, - "global": 138 /* GlobalKeyword */, + "readonly": 130 /* ReadonlyKeyword */, + "require": 131 /* RequireKeyword */, + "global": 139 /* GlobalKeyword */, "return": 95 /* ReturnKeyword */, - "set": 132 /* SetKeyword */, + "set": 133 /* SetKeyword */, "static": 114 /* StaticKeyword */, - "string": 133 /* StringKeyword */, + "string": 134 /* StringKeyword */, "super": 96 /* SuperKeyword */, "switch": 97 /* SwitchKeyword */, - "symbol": 134 /* SymbolKeyword */, + "symbol": 135 /* SymbolKeyword */, "this": 98 /* ThisKeyword */, "throw": 99 /* ThrowKeyword */, "true": 100 /* TrueKeyword */, "try": 101 /* TryKeyword */, - "type": 135 /* TypeKeyword */, + "type": 136 /* TypeKeyword */, "typeof": 102 /* TypeOfKeyword */, - "undefined": 136 /* UndefinedKeyword */, + "undefined": 137 /* UndefinedKeyword */, "var": 103 /* VarKeyword */, "void": 104 /* VoidKeyword */, "while": 105 /* WhileKeyword */, @@ -4503,7 +4679,7 @@ var ts; "yield": 115 /* YieldKeyword */, "async": 119 /* AsyncKeyword */, "await": 120 /* AwaitKeyword */, - "of": 139 /* OfKeyword */, + "of": 140 /* OfKeyword */, "{": 16 /* OpenBraceToken */, "}": 17 /* CloseBraceToken */, "(": 18 /* OpenParenToken */, @@ -6057,9 +6233,9 @@ var ts; pos++; return token = 22 /* DotToken */; } - if (isIdentifierStart(ch, 4 /* Latest */)) { + if (isIdentifierStart(ch, 5 /* Latest */)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4 /* Latest */) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5 /* Latest */) && pos < end) { pos++; } return token = 70 /* Identifier */; @@ -6227,7 +6403,9 @@ var ts; ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; /* @internal */ function moduleResolutionIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport; + return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && + oldResolution.extension === newResolution.extension && + oldResolution.resolvedFileName === newResolution.resolvedFileName; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; /* @internal */ @@ -6256,28 +6434,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 2097152 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 4194304 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 4194304 /* HasAggregatedChildData */)) { + if (!(node.flags & 8388608 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 524288 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 2097152 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 4194304 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 4194304 /* HasAggregatedChildData */; + node.flags |= 8388608 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 256 /* SourceFile */) { + while (node && node.kind !== 260 /* SourceFile */) { node = node.parent; } return node; @@ -6285,11 +6463,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: return true; } return false; @@ -6380,18 +6558,18 @@ 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 === 286 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 290 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 257 /* FirstJSDocNode */ && node.kind <= 282 /* LastJSDocNode */; + return node.kind >= 261 /* FirstJSDocNode */ && node.kind <= 286 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 273 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; + return node.kind >= 277 /* FirstJSDocTagNode */ && node.kind <= 289 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6495,25 +6673,26 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 219 /* VariableDeclaration */ && node.parent.kind === 252 /* CatchClause */; + return node.kind === 222 /* VariableDeclaration */ && node.parent.kind === 255 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 226 /* ModuleDeclaration */ && + return node && node.kind === 229 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; + /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ function isShorthandAmbientModuleSymbol(moduleSymbol) { return isShorthandAmbientModule(moduleSymbol.valueDeclaration); } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node.kind === 226 /* ModuleDeclaration */ && (!node.body); + return node.kind === 229 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 256 /* SourceFile */ || - node.kind === 226 /* ModuleDeclaration */ || + return node.kind === 260 /* SourceFile */ || + node.kind === 229 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6529,9 +6708,9 @@ var ts; return false; } switch (node.parent.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: return ts.isExternalModule(node.parent); - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6539,22 +6718,22 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isBlockScope(node, parentNode) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 252 /* CatchClause */: - case 226 /* ModuleDeclaration */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 260 /* SourceFile */: + case 231 /* CaseBlock */: + case 255 /* CatchClause */: + case 229 /* ModuleDeclaration */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return true; - case 200 /* Block */: + case 203 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -6581,12 +6760,42 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getTextOfPropertyName(name) { + switch (name.kind) { + case 70 /* Identifier */: + return name.text; + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + return name.text; + case 142 /* ComputedPropertyName */: + if (isStringOrNumericLiteral(name.expression.kind)) { + return name.expression.text; + } + } + return undefined; + } + ts.getTextOfPropertyName = getTextOfPropertyName; + function entityNameToString(name) { + switch (name.kind) { + case 70 /* Identifier */: + return getFullWidth(name) === 0 ? unescapeIdentifier(name.text) : getTextOfNode(name); + case 141 /* QualifiedName */: + return entityNameToString(name.left) + "." + entityNameToString(name.right); + case 176 /* PropertyAccessExpression */: + return entityNameToString(name.expression) + "." + entityNameToString(name.name); + } + } + ts.entityNameToString = entityNameToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { var sourceFile = getSourceFileOfNode(node); + return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); + } + ts.createDiagnosticForNode = createDiagnosticForNode; + function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2) { var span = getErrorSpanForNode(sourceFile, node); return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2); } - ts.createDiagnosticForNode = createDiagnosticForNode; + ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -6609,7 +6818,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 200 /* Block */) { + if (node.body && node.body.kind === 203 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6623,7 +6832,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* 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 @@ -6632,23 +6841,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 224 /* TypeAliasDeclaration */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 227 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -6671,7 +6880,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 225 /* EnumDeclaration */ && isConst(node); + return node.kind === 228 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -6684,11 +6893,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 175 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 178 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 203 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; + return node.kind === 206 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -6704,10 +6913,10 @@ var ts; } ts.getJsDocComments = getJsDocComments; function getJsDocCommentsFromText(node, text) { - var commentRanges = (node.kind === 143 /* Parameter */ || - node.kind === 142 /* TypeParameter */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 181 /* ArrowFunction */) ? + var commentRanges = (node.kind === 144 /* Parameter */ || + node.kind === 143 /* TypeParameter */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 184 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, isJsDocComment); @@ -6723,39 +6932,39 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (155 /* FirstTypeNode */ <= node.kind && node.kind <= 167 /* LastTypeNode */) { + if (156 /* FirstTypeNode */ <= node.kind && node.kind <= 170 /* LastTypeNode */) { return true; } switch (node.kind) { case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 135 /* SymbolKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: return true; case 104 /* VoidKeyword */: - return node.parent.kind !== 184 /* VoidExpression */; - case 195 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 187 /* VoidExpression */; + case 198 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 70 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 176 /* 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 === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 140 /* QualifiedName */: - case 173 /* PropertyAccessExpression */: + ts.Debug.assert(node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 176 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 141 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: case 98 /* ThisKeyword */: var parent_1 = node.parent; - if (parent_1.kind === 159 /* TypeQuery */) { + if (parent_1.kind === 160 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -6764,38 +6973,38 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (155 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 167 /* LastTypeNode */) { + if (156 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 170 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return node === parent_1.constraint; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 143 /* Parameter */: - case 219 /* VariableDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 144 /* Parameter */: + case 222 /* VariableDeclaration */: return node === parent_1.type; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return node === parent_1.type; - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return node === parent_1.type; - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return node === parent_1.type; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -6809,23 +7018,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitor(node); - case 228 /* CaseBlock */: - case 200 /* Block */: - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 213 /* WithStatement */: - case 214 /* SwitchStatement */: - case 249 /* CaseClause */: - case 250 /* DefaultClause */: - case 215 /* LabeledStatement */: - case 217 /* TryStatement */: - case 252 /* CatchClause */: + case 231 /* CaseBlock */: + case 203 /* Block */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 216 /* WithStatement */: + case 217 /* SwitchStatement */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: + case 218 /* LabeledStatement */: + case 220 /* TryStatement */: + case 255 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -6835,18 +7044,18 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 225 /* EnumDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. @@ -6854,7 +7063,7 @@ var ts; default: if (isFunctionLike(node)) { var name_5 = node.name; - if (name_5 && name_5.kind === 141 /* ComputedPropertyName */) { + if (name_5 && name_5.kind === 142 /* 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(name_5.expression); @@ -6873,14 +7082,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 170 /* BindingElement */: - case 255 /* EnumMember */: - case 143 /* Parameter */: - case 253 /* PropertyAssignment */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 254 /* ShorthandPropertyAssignment */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 259 /* EnumMember */: + case 144 /* Parameter */: + case 256 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 257 /* ShorthandPropertyAssignment */: + case 222 /* VariableDeclaration */: return true; } } @@ -6888,11 +7097,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */); + return node && (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */); + return node && (node.kind === 225 /* ClassDeclaration */ || node.kind === 196 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -6901,19 +7110,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return true; } return false; @@ -6921,13 +7130,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return true; } return false; @@ -6935,30 +7144,30 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: return true; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isFunctionBlock(node) { - return node && node.kind === 200 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 203 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 148 /* MethodDeclaration */ && node.parent.kind === 172 /* ObjectLiteralExpression */; + return node && node.kind === 149 /* MethodDeclaration */ && node.parent.kind === 175 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 148 /* MethodDeclaration */ && - (node.parent.kind === 172 /* ObjectLiteralExpression */ || - node.parent.kind === 193 /* ClassExpression */); + return node.kind === 149 /* MethodDeclaration */ && + (node.parent.kind === 175 /* ObjectLiteralExpression */ || + node.parent.kind === 196 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -6994,7 +7203,7 @@ var ts; return undefined; } switch (node.kind) { - case 141 /* ComputedPropertyName */: + case 142 /* 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 @@ -7009,9 +7218,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 144 /* Parameter */ && 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; @@ -7022,26 +7231,26 @@ var ts; node = node.parent; } break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 226 /* ModuleDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 225 /* EnumDeclaration */: - case 256 /* SourceFile */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 229 /* ModuleDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 228 /* EnumDeclaration */: + case 260 /* SourceFile */: return node; } } @@ -7062,26 +7271,26 @@ var ts; return node; } switch (node.kind) { - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: node = node.parent; break; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return node; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 143 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 144 /* Parameter */ && 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; @@ -7097,14 +7306,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */) { + if (func.kind === 183 /* FunctionExpression */ || func.kind === 184 /* ArrowFunction */) { var prev = func; var parent_2 = func.parent; - while (parent_2.kind === 179 /* ParenthesizedExpression */) { + while (parent_2.kind === 182 /* ParenthesizedExpression */) { prev = parent_2; parent_2 = parent_2.parent; } - if (parent_2.kind === 175 /* CallExpression */ && parent_2.expression === prev) { + if (parent_2.kind === 178 /* CallExpression */ && parent_2.expression === prev) { return parent_2; } } @@ -7115,32 +7324,32 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 173 /* PropertyAccessExpression */ || kind === 174 /* ElementAccessExpression */) + return (kind === 176 /* PropertyAccessExpression */ || kind === 177 /* ElementAccessExpression */) && node.expression.kind === 96 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { - if (node) { - switch (node.kind) { - case 156 /* TypeReference */: - return node.typeName; - case 195 /* ExpressionWithTypeArguments */: - ts.Debug.assert(isEntityNameExpression(node.expression)); - return node.expression; - case 70 /* Identifier */: - case 140 /* QualifiedName */: - return node; - } + switch (node.kind) { + case 157 /* TypeReference */: + case 271 /* JSDocTypeReference */: + return node.typeName; + case 198 /* ExpressionWithTypeArguments */: + return isEntityNameExpression(node.expression) + ? node.expression + : undefined; + case 70 /* Identifier */: + case 141 /* QualifiedName */: + return node; } return undefined; } ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 177 /* TaggedTemplateExpression */: - case 144 /* Decorator */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 180 /* TaggedTemplateExpression */: + case 145 /* Decorator */: return true; default: return false; @@ -7148,7 +7357,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -7157,25 +7366,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: // classes are valid targets return true; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 222 /* ClassDeclaration */; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: + return node.parent.kind === 225 /* ClassDeclaration */; + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && node.parent.kind === 222 /* ClassDeclaration */; - case 143 /* Parameter */: + && node.parent.kind === 225 /* ClassDeclaration */; + case 144 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return node.parent.body !== undefined - && (node.parent.kind === 149 /* Constructor */ - || node.parent.kind === 148 /* MethodDeclaration */ - || node.parent.kind === 151 /* SetAccessor */) - && node.parent.parent.kind === 222 /* ClassDeclaration */; + && (node.parent.kind === 150 /* Constructor */ + || node.parent.kind === 149 /* MethodDeclaration */ + || node.parent.kind === 152 /* SetAccessor */) + && node.parent.parent.kind === 225 /* ClassDeclaration */; } return false; } @@ -7191,19 +7400,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 148 /* MethodDeclaration */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 152 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 244 /* JsxOpeningElement */ || - parent.kind === 243 /* JsxSelfClosingElement */ || - parent.kind === 245 /* JsxClosingElement */) { + if (parent.kind === 247 /* JsxOpeningElement */ || + parent.kind === 246 /* JsxSelfClosingElement */ || + parent.kind === 248 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7217,43 +7426,43 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 11 /* RegularExpressionLiteral */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 177 /* TaggedTemplateExpression */: - case 196 /* AsExpression */: - case 178 /* TypeAssertionExpression */: - case 197 /* NonNullExpression */: - case 179 /* ParenthesizedExpression */: - case 180 /* FunctionExpression */: - case 193 /* ClassExpression */: - case 181 /* ArrowFunction */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 183 /* TypeOfExpression */: - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: - case 188 /* BinaryExpression */: - case 189 /* ConditionalExpression */: - case 192 /* SpreadElementExpression */: - case 190 /* TemplateExpression */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 180 /* TaggedTemplateExpression */: + case 199 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 200 /* NonNullExpression */: + case 182 /* ParenthesizedExpression */: + case 183 /* FunctionExpression */: + case 196 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 186 /* TypeOfExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + case 191 /* BinaryExpression */: + case 192 /* ConditionalExpression */: + case 195 /* SpreadElement */: + case 193 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: - case 194 /* OmittedExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 191 /* YieldExpression */: - case 185 /* AwaitExpression */: + case 197 /* OmittedExpression */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: + case 194 /* YieldExpression */: + case 188 /* AwaitExpression */: return true; - case 140 /* QualifiedName */: - while (node.parent.kind === 140 /* QualifiedName */) { + case 141 /* QualifiedName */: + while (node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node); case 70 /* Identifier */: - if (node.parent.kind === 159 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 160 /* TypeQuery */ || isJSXTagName(node)) { return true; } // fall through @@ -7262,47 +7471,47 @@ var ts; case 98 /* ThisKeyword */: var parent_3 = node.parent; switch (parent_3.kind) { - case 219 /* VariableDeclaration */: - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 255 /* EnumMember */: - case 253 /* PropertyAssignment */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 259 /* EnumMember */: + case 256 /* PropertyAssignment */: + case 173 /* BindingElement */: return parent_3.initializer === node; - case 203 /* ExpressionStatement */: - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 212 /* ReturnStatement */: - case 213 /* WithStatement */: - case 214 /* SwitchStatement */: - case 249 /* CaseClause */: - case 216 /* ThrowStatement */: - case 214 /* SwitchStatement */: + case 206 /* ExpressionStatement */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 215 /* ReturnStatement */: + case 216 /* WithStatement */: + case 217 /* SwitchStatement */: + case 252 /* CaseClause */: + case 219 /* ThrowStatement */: + case 217 /* SwitchStatement */: return parent_3.expression === node; - case 207 /* ForStatement */: + case 210 /* ForStatement */: var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 223 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 220 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 223 /* VariableDeclarationList */) || forInStatement.expression === node; - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return node === parent_3.expression; - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return node === parent_3.expression; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return node === parent_3.expression; - case 144 /* Decorator */: - case 248 /* JsxExpression */: - case 247 /* JsxSpreadAttribute */: + case 145 /* Decorator */: + case 251 /* JsxExpression */: + case 250 /* JsxSpreadAttribute */: return true; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); default: if (isPartOfExpression(parent_3)) { @@ -7320,7 +7529,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */; + return node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 244 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7329,7 +7538,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 241 /* ExternalModuleReference */; + return node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 244 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7337,7 +7546,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 1048576 /* JavaScriptFile */); + return node && !!(node.flags & 2097152 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7347,7 +7556,7 @@ var ts; */ function isRequireCall(expression, checkArgumentIsStringLiteral) { // of the form 'require("name")' - var isRequire = expression.kind === 175 /* CallExpression */ && + var isRequire = expression.kind === 178 /* CallExpression */ && expression.expression.kind === 70 /* Identifier */ && expression.expression.text === "require" && expression.arguments.length === 1; @@ -7363,9 +7572,9 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 219 /* VariableDeclaration */) { + if (s.valueDeclaration && s.valueDeclaration.kind === 222 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 180 /* FunctionExpression */; + return declaration.initializer && declaration.initializer.kind === 183 /* FunctionExpression */; } return false; } @@ -7376,11 +7585,11 @@ var ts; if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 188 /* BinaryExpression */) { + if (expression.kind !== 191 /* BinaryExpression */) { return 0 /* None */; } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 173 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 176 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; @@ -7398,7 +7607,7 @@ var ts; else if (lhs.expression.kind === 98 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 173 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 176 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { @@ -7416,35 +7625,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 234 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 241 /* ExternalModuleReference */) { + if (reference.kind === 244 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 237 /* ExportDeclaration */) { + if (node.kind === 240 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 226 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 229 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 236 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 231 /* ImportDeclaration */ + return node.kind === 234 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7452,13 +7661,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 143 /* Parameter */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 254 /* ShorthandPropertyAssignment */: - case 253 /* PropertyAssignment */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 257 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7466,9 +7675,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 269 /* JSDocFunctionType */ && + return node.kind === 273 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 271 /* JSDocConstructorType */; + node.parameters[0].type.kind === 275 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind, checkParentVariableStatement) { @@ -7528,34 +7737,34 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && (node.parent).initializer === node && - node.parent.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.parent.kind === 204 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 201 /* VariableStatement */; + node.parent.parent.kind === 204 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : isVariableOfVariableDeclarationStatement ? node.parent.parent : undefined; if (variableStatementNode) { result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); } - if (node.kind === 226 /* ModuleDeclaration */ && - node.parent && node.parent.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */ && + node.parent && node.parent.kind === 229 /* ModuleDeclaration */) { result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression var parent_4 = node.parent; var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 188 /* BinaryExpression */ && + parent_4.kind === 191 /* BinaryExpression */ && parent_4.operatorToken.kind === 57 /* EqualsToken */ && - parent_4.parent.kind === 203 /* ExpressionStatement */; + parent_4.parent.kind === 206 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 253 /* PropertyAssignment */; + var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 256 /* PropertyAssignment */; if (isPropertyAssignmentExpression) { result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); } // Pull parameter comments from declaring function as well - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); if (paramTags) { result = append(result, getTags(paramTags)); @@ -7581,14 +7790,14 @@ var ts; if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70 /* Identifier */) { var name_6 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 275 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 279 /* JSDocParameterTag */ && tag.parameterName.text === name_6; }); if (paramTags) { return paramTags; } @@ -7600,15 +7809,15 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 277 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 281 /* JSDocTypeTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 276 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); + return getJSDocTag(node, 280 /* JSDocReturnTag */, /*checkParentVariableStatement*/ true); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 278 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); + return getJSDocTag(node, 282 /* JSDocTemplateTag */, /*checkParentVariableStatement*/ false); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { @@ -7622,7 +7831,7 @@ var ts; } for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { var tag = jsDocTags_2[_i]; - if (tag.kind === 275 /* JSDocParameterTag */) { + if (tag.kind === 279 /* JSDocParameterTag */) { var parameterTag = tag; if (parameterTag.parameterName.text === parameterName) { return parameterTag; @@ -7642,13 +7851,13 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 1048576 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 270 /* JSDocVariadicType */) { + if (node && (node.flags & 2097152 /* JavaScriptFile */)) { + if (node.type && node.type.kind === 274 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 270 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 274 /* JSDocVariadicType */; } } return isDeclaredRestParam(node); @@ -7658,29 +7867,53 @@ var ts; return node && node.dotDotDotToken !== undefined; } ts.isDeclaredRestParam = isDeclaredRestParam; + var AssignmentKind; + (function (AssignmentKind) { + AssignmentKind[AssignmentKind["None"] = 0] = "None"; + AssignmentKind[AssignmentKind["Definite"] = 1] = "Definite"; + AssignmentKind[AssignmentKind["Compound"] = 2] = "Compound"; + })(AssignmentKind = ts.AssignmentKind || (ts.AssignmentKind = {})); + function getAssignmentTargetKind(node) { + var parent = node.parent; + while (true) { + switch (parent.kind) { + case 191 /* BinaryExpression */: + var binaryOperator = parent.operatorToken.kind; + return isAssignmentOperator(binaryOperator) && parent.left === node ? + binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + 0 /* None */; + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + var unaryOperator = parent.operator; + return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; + case 182 /* ParenthesizedExpression */: + case 174 /* ArrayLiteralExpression */: + case 195 /* SpreadElement */: + node = parent; + break; + case 257 /* ShorthandPropertyAssignment */: + if (parent.name !== node) { + return 0 /* None */; + } + // Fall through + case 256 /* PropertyAssignment */: + node = parent.parent; + break; + default: + return 0 /* None */; + } + parent = node.parent; + } + } + ts.getAssignmentTargetKind = getAssignmentTargetKind; // A node is an assignment target if it is on the left hand side of an '=' token, if it is parented by a property // assignment in an object literal that is an assignment target, or if it is parented by an array literal that is // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { - while (node.parent.kind === 179 /* ParenthesizedExpression */) { - node = node.parent; - } - while (true) { - var parent_5 = node.parent; - if (parent_5.kind === 171 /* ArrayLiteralExpression */ || parent_5.kind === 192 /* SpreadElementExpression */) { - node = parent_5; - continue; - } - if (parent_5.kind === 253 /* PropertyAssignment */ || parent_5.kind === 254 /* ShorthandPropertyAssignment */) { - node = parent_5.parent; - continue; - } - return parent_5.kind === 188 /* BinaryExpression */ && - isAssignmentOperator(parent_5.operatorToken.kind) && - parent_5.left === node || - (parent_5.kind === 208 /* ForInStatement */ || parent_5.kind === 209 /* ForOfStatement */) && - parent_5.initializer === node; - } + return getAssignmentTargetKind(node) !== 0 /* None */; } ts.isAssignmentTarget = isAssignmentTarget; function isNodeDescendantOf(node, ancestor) { @@ -7694,7 +7927,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 256 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 260 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -7708,7 +7941,7 @@ var ts; return false; } var parent = name.parent; - if (parent.kind === 235 /* ImportSpecifier */ || parent.kind === 239 /* ExportSpecifier */) { + if (parent.kind === 238 /* ImportSpecifier */ || parent.kind === 242 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -7721,7 +7954,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 141 /* ComputedPropertyName */ && + node.parent.kind === 142 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -7729,31 +7962,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 255 /* EnumMember */: - case 253 /* PropertyAssignment */: - case 173 /* PropertyAccessExpression */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 259 /* EnumMember */: + case 256 /* PropertyAssignment */: + case 176 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 140 /* QualifiedName */) { + while (parent.kind === 141 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 159 /* TypeQuery */; + return parent.kind === 160 /* TypeQuery */; } return false; - case 170 /* BindingElement */: - case 235 /* ImportSpecifier */: + case 173 /* BindingElement */: + case 238 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -7769,13 +8002,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */ || - node.kind === 229 /* NamespaceExportDeclaration */ || - node.kind === 232 /* ImportClause */ && !!node.name || - node.kind === 233 /* NamespaceImport */ || - node.kind === 235 /* ImportSpecifier */ || - node.kind === 239 /* ExportSpecifier */ || - node.kind === 236 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 233 /* ImportEqualsDeclaration */ || + node.kind === 232 /* NamespaceExportDeclaration */ || + node.kind === 235 /* ImportClause */ && !!node.name || + node.kind === 236 /* NamespaceImport */ || + node.kind === 238 /* ImportSpecifier */ || + node.kind === 242 /* ExportSpecifier */ || + node.kind === 239 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -7861,7 +8094,7 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 139 /* LastKeyword */; + return 71 /* FirstKeyword */ <= token && token <= 140 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { @@ -7888,7 +8121,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 141 /* ComputedPropertyName */ && + return name.kind === 142 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression.kind) && !isWellKnownSymbolSyntactically(name.expression); } @@ -7903,10 +8136,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 143 /* Parameter */) { + if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 144 /* Parameter */) { return name.text; } - if (name.kind === 141 /* ComputedPropertyName */) { + if (name.kind === 142 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -7945,7 +8178,7 @@ var ts; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: case 114 /* StaticKeyword */: return true; } @@ -7954,11 +8187,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 143 /* Parameter */; + return root.kind === 144 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 170 /* BindingElement */) { + while (node.kind === 173 /* BindingElement */) { node = node.parent.parent; } return node; @@ -7966,15 +8199,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 149 /* Constructor */ - || kind === 180 /* FunctionExpression */ - || kind === 221 /* FunctionDeclaration */ - || kind === 181 /* ArrowFunction */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 226 /* ModuleDeclaration */ - || kind === 256 /* SourceFile */; + return kind === 150 /* Constructor */ + || kind === 183 /* FunctionExpression */ + || kind === 224 /* FunctionDeclaration */ + || kind === 184 /* ArrowFunction */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 229 /* ModuleDeclaration */ + || kind === 260 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -7982,13 +8215,13 @@ var ts; || ts.positionIsSynthesized(node.end); } ts.nodeIsSynthesized = nodeIsSynthesized; - function getOriginalNode(node) { + function getOriginalNode(node, nodeTest) { if (node) { while (node.original !== undefined) { node = node.original; } } - return node; + return !nodeTest || nodeTest(node) ? node : undefined; } ts.getOriginalNode = getOriginalNode; /** @@ -8028,30 +8261,30 @@ var ts; return node ? ts.getNodeId(node) : 0; } ts.getOriginalNodeId = getOriginalNodeId; + var Associativity; (function (Associativity) { Associativity[Associativity["Left"] = 0] = "Left"; Associativity[Associativity["Right"] = 1] = "Right"; - })(ts.Associativity || (ts.Associativity = {})); - var Associativity = ts.Associativity; + })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 176 /* NewExpression */: + case 179 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: - case 189 /* ConditionalExpression */: - case 191 /* YieldExpression */: + case 189 /* PrefixUnaryExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 188 /* AwaitExpression */: + case 192 /* ConditionalExpression */: + case 194 /* YieldExpression */: return 1 /* Right */; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (operator) { case 39 /* AsteriskAsteriskToken */: case 57 /* EqualsToken */: @@ -8075,15 +8308,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 176 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 179 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 188 /* BinaryExpression */) { + if (expression.kind === 191 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 186 /* PrefixUnaryExpression */ || expression.kind === 187 /* PostfixUnaryExpression */) { + else if (expression.kind === 189 /* PrefixUnaryExpression */ || expression.kind === 190 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8101,36 +8334,36 @@ var ts; case 85 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 196 /* ClassExpression */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: case 11 /* RegularExpressionLiteral */: case 12 /* NoSubstitutionTemplateLiteral */: - case 190 /* TemplateExpression */: - case 179 /* ParenthesizedExpression */: - case 194 /* OmittedExpression */: + case 193 /* TemplateExpression */: + case 182 /* ParenthesizedExpression */: + case 197 /* OmittedExpression */: return 19; - case 177 /* TaggedTemplateExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 180 /* TaggedTemplateExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: return 18; - case 176 /* NewExpression */: + case 179 /* NewExpression */: return hasArguments ? 18 : 17; - case 175 /* CallExpression */: + case 178 /* CallExpression */: return 17; - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return 16; - case 186 /* PrefixUnaryExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 182 /* DeleteExpression */: - case 185 /* AwaitExpression */: + case 189 /* PrefixUnaryExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 185 /* DeleteExpression */: + case 188 /* AwaitExpression */: return 15; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (operatorKind) { case 50 /* ExclamationToken */: case 51 /* TildeToken */: @@ -8188,11 +8421,11 @@ var ts; default: return -1; } - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return 4; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return 2; - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return 1; default: return -1; @@ -8462,14 +8695,17 @@ var ts; if (options.outFile || options.out) { var moduleKind = ts.getEmitModuleKind(options); var moduleEmitEnabled = moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System; - var sourceFiles = host.getSourceFiles(); + var sourceFiles = getAllEmittableSourceFiles(); // Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified return ts.filter(sourceFiles, moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles() : [targetSourceFile]; return ts.filter(sourceFiles, isNonDeclarationFile); } + function getAllEmittableSourceFiles() { + return options.noEmitForJsFiles ? ts.filter(host.getSourceFiles(), function (sourceFile) { return !isSourceFileJavaScript(sourceFile); }) : host.getSourceFiles(); + } } ts.getSourceFilesToEmit = getSourceFilesToEmit; function isNonDeclarationFile(sourceFile) { @@ -8554,7 +8790,7 @@ var ts; onBundledEmit(host); } else { - var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile]; + var sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit(host) : [targetSourceFile]; for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; // Don't emit if source file is a declaration file, or was located under node_modules @@ -8591,7 +8827,7 @@ var ts; function onBundledEmit(host) { // Can emit only sources that are not declaration file and are either non module code or module with // --module or --target es6 specified. Files included by searching under node_modules are also not emitted. - var bundledSources = ts.filter(host.getSourceFiles(), function (sourceFile) { return !isDeclarationFile(sourceFile) && + var bundledSources = ts.filter(getSourceFilesToEmit(host), function (sourceFile) { return !isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile) && (!ts.isExternalModule(sourceFile) || !!ts.getEmitModuleKind(options)); }); @@ -8631,7 +8867,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 149 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 150 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -8673,10 +8909,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 150 /* GetAccessor */) { + if (accessor.kind === 151 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 151 /* SetAccessor */) { + else if (accessor.kind === 152 /* SetAccessor */) { setAccessor = accessor; } else { @@ -8685,7 +8921,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 150 /* GetAccessor */ || member.kind === 151 /* SetAccessor */) + if ((member.kind === 151 /* GetAccessor */ || member.kind === 152 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8696,10 +8932,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 150 /* GetAccessor */ && !getAccessor) { + if (member.kind === 151 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 151 /* SetAccessor */ && !setAccessor) { + if (member.kind === 152 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -8945,7 +9181,7 @@ var ts; case 75 /* ConstKeyword */: return 2048 /* Const */; case 78 /* DefaultKeyword */: return 512 /* Default */; case 119 /* AsyncKeyword */: return 256 /* Async */; - case 129 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 130 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } @@ -8962,19 +9198,25 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ && + if (node.kind === 198 /* ExpressionWithTypeArguments */ && node.parent.token === 84 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; + function isAssignmentExpression(node) { + return isBinaryExpression(node) + && isAssignmentOperator(node.operatorToken.kind) + && isLeftHandSideExpression(node.left); + } + ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { if (isBinaryExpression(node)) { if (node.operatorToken.kind === 57 /* EqualsToken */) { var kind = node.left.kind; - return kind === 172 /* ObjectLiteralExpression */ - || kind === 171 /* ArrayLiteralExpression */; + return kind === 175 /* ObjectLiteralExpression */ + || kind === 174 /* ArrayLiteralExpression */; } } return false; @@ -9003,20 +9245,20 @@ var ts; ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { return node.kind === 70 /* Identifier */ || - node.kind === 173 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + node.kind === 176 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteralOrArrayLiteral(expression) { var kind = expression.kind; - if (kind === 172 /* ObjectLiteralExpression */) { + if (kind === 175 /* ObjectLiteralExpression */) { return expression.properties.length === 0; } - if (kind === 171 /* ArrayLiteralExpression */) { + if (kind === 174 /* ArrayLiteralExpression */) { return expression.elements.length === 0; } return false; @@ -9178,39 +9420,39 @@ var ts; || kind === 94 /* NullKeyword */) { return true; } - else if (kind === 173 /* PropertyAccessExpression */) { + else if (kind === 176 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 174 /* ElementAccessExpression */) { + else if (kind === 177 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */) { + else if (kind === 189 /* PrefixUnaryExpression */ + || kind === 190 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 188 /* BinaryExpression */) { + else if (kind === 191 /* BinaryExpression */) { return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 189 /* ConditionalExpression */) { + else if (kind === 192 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 184 /* VoidExpression */ - || kind === 183 /* TypeOfExpression */ - || kind === 182 /* DeleteExpression */) { + else if (kind === 187 /* VoidExpression */ + || kind === 186 /* TypeOfExpression */ + || kind === 185 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 171 /* ArrayLiteralExpression */) { + else if (kind === 174 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 172 /* ObjectLiteralExpression */) { + else if (kind === 175 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 175 /* CallExpression */) { + else if (kind === 178 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9369,28 +9611,31 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile) { + function collectExternalModuleInfo(sourceFile, resolver) { var externalImports = []; var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var hasExportDefault = false; var exportEquals = undefined; var hasExportStarsToExportValues = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 230 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + case 233 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 244 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -9406,22 +9651,111 @@ var ts; // export { x, y } for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { var specifier = _c[_b]; - var name_8 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_8] || (exportSpecifiers[name_8] = [])).push(specifier); + if (!uniqueExports[specifier.name.text]) { + var name_8 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_8.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_8) + || resolver.getReferencedValueDeclaration(name_8); + if (decl) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = specifier.name; + } } } break; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; + case 204 /* VariableStatement */: + if (hasModifier(node, 1 /* Export */)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + collectExportedVariableInfo(decl, uniqueExports); + } + } + break; + case 224 /* FunctionDeclaration */: + if (hasModifier(node, 1 /* Export */)) { + if (hasModifier(node, 512 /* Default */)) { + // export default function() { } + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + // export function x() { } + var name_9 = node.name; + if (!uniqueExports[name_9.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_9); + uniqueExports[name_9.text] = name_9; + } + } + } + break; + case 225 /* ClassDeclaration */: + if (hasModifier(node, 1 /* Export */)) { + if (hasModifier(node, 512 /* Default */)) { + // export default class { } + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + // export class x { } + var name_10 = node.name; + if (!uniqueExports[name_10.text]) { + ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_10); + uniqueExports[name_10.text] = name_10; + } + } + } + break; } } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues }; + var exportedNames; + for (var key in uniqueExports) { + exportedNames = ts.append(exportedNames, uniqueExports[key]); + } + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; } ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports) { + if (isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!isOmittedExpression(element)) { + collectExportedVariableInfo(element, uniqueExports); + } + } + } + else if (!isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = decl.name; + } + } + } + /** + * Determines whether a name was originally the declaration name of an enum or namespace + * declaration. + */ + function isDeclarationNameOfEnumOrNamespace(node) { + var parseNode = getParseTreeNode(node); + if (parseNode) { + switch (parseNode.parent.kind) { + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + return parseNode === parseNode.parent.name; + } + } + return false; + } + ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace; function getInitializedVariables(node) { return ts.filter(node.declarations, isInitializedVariable); } @@ -9436,7 +9770,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 225 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9513,16 +9847,16 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 140 /* QualifiedName */; + return node.kind === 141 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 141 /* ComputedPropertyName */; + return node.kind === 142 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 140 /* QualifiedName */ + return kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isEntityName = isEntityName; @@ -9531,7 +9865,7 @@ var ts; return kind === 70 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 141 /* ComputedPropertyName */; + || kind === 142 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { @@ -9543,60 +9877,61 @@ var ts; function isBindingName(node) { var kind = node.kind; return kind === 70 /* Identifier */ - || kind === 168 /* ObjectBindingPattern */ - || kind === 169 /* ArrayBindingPattern */; + || kind === 171 /* ObjectBindingPattern */ + || kind === 172 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 142 /* TypeParameter */; + return node.kind === 143 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 143 /* Parameter */; + return node.kind === 144 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 144 /* Decorator */; + return node.kind === 145 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 148 /* MethodDeclaration */; + return node.kind === 149 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 149 /* Constructor */ - || kind === 146 /* PropertyDeclaration */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 154 /* IndexSignature */ - || kind === 199 /* SemicolonClassElement */; + return kind === 150 /* Constructor */ + || kind === 147 /* PropertyDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 155 /* IndexSignature */ + || kind === 202 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 253 /* PropertyAssignment */ - || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 240 /* MissingDeclaration */; + return kind === 256 /* PropertyAssignment */ + || kind === 257 /* ShorthandPropertyAssignment */ + || kind === 258 /* SpreadAssignment */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 243 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) + return (kind >= 156 /* FirstTypeNode */ && kind <= 170 /* LastTypeNode */) || kind === 118 /* AnyKeyword */ - || kind === 131 /* NumberKeyword */ + || kind === 132 /* NumberKeyword */ || kind === 121 /* BooleanKeyword */ - || kind === 133 /* StringKeyword */ - || kind === 134 /* SymbolKeyword */ + || kind === 134 /* StringKeyword */ + || kind === 135 /* SymbolKeyword */ || kind === 104 /* VoidKeyword */ - || kind === 128 /* NeverKeyword */ - || kind === 195 /* ExpressionWithTypeArguments */; + || kind === 129 /* NeverKeyword */ + || kind === 198 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9611,95 +9946,103 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 169 /* ArrayBindingPattern */ - || kind === 168 /* ObjectBindingPattern */; + return kind === 172 /* ArrayBindingPattern */ + || kind === 171 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isBindingElement(node) { - return node.kind === 170 /* BindingElement */; + return node.kind === 173 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 170 /* BindingElement */ - || kind === 194 /* OmittedExpression */; + return kind === 173 /* BindingElement */ + || kind === 197 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; // Expression + function isArrayLiteralExpression(node) { + return node.kind === 174 /* ArrayLiteralExpression */; + } + ts.isArrayLiteralExpression = isArrayLiteralExpression; + function isObjectLiteralExpression(node) { + return node.kind === 175 /* ObjectLiteralExpression */; + } + ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 173 /* PropertyAccessExpression */; + return node.kind === 176 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 174 /* ElementAccessExpression */; + return node.kind === 177 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 188 /* BinaryExpression */; + return node.kind === 191 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 189 /* ConditionalExpression */; + return node.kind === 192 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 175 /* CallExpression */; + return node.kind === 178 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 190 /* TemplateExpression */ + return kind === 193 /* TemplateExpression */ || kind === 12 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isSpreadElementExpression(node) { - return node.kind === 192 /* SpreadElementExpression */; + function isSpreadExpression(node) { + return node.kind === 195 /* SpreadElement */; } - ts.isSpreadElementExpression = isSpreadElementExpression; + ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 195 /* ExpressionWithTypeArguments */; + return node.kind === 198 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 173 /* PropertyAccessExpression */ - || kind === 174 /* ElementAccessExpression */ - || kind === 176 /* NewExpression */ - || kind === 175 /* CallExpression */ - || kind === 242 /* JsxElement */ - || kind === 243 /* JsxSelfClosingElement */ - || kind === 177 /* TaggedTemplateExpression */ - || kind === 171 /* ArrayLiteralExpression */ - || kind === 179 /* ParenthesizedExpression */ - || kind === 172 /* ObjectLiteralExpression */ - || kind === 193 /* ClassExpression */ - || kind === 180 /* FunctionExpression */ + return kind === 176 /* PropertyAccessExpression */ + || kind === 177 /* ElementAccessExpression */ + || kind === 179 /* NewExpression */ + || kind === 178 /* CallExpression */ + || kind === 245 /* JsxElement */ + || kind === 246 /* JsxSelfClosingElement */ + || kind === 180 /* TaggedTemplateExpression */ + || kind === 174 /* ArrayLiteralExpression */ + || kind === 182 /* ParenthesizedExpression */ + || kind === 175 /* ObjectLiteralExpression */ + || kind === 196 /* ClassExpression */ + || kind === 183 /* FunctionExpression */ || kind === 70 /* Identifier */ || kind === 11 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 190 /* TemplateExpression */ + || kind === 193 /* TemplateExpression */ || kind === 85 /* FalseKeyword */ || kind === 94 /* NullKeyword */ || kind === 98 /* ThisKeyword */ || kind === 100 /* TrueKeyword */ || kind === 96 /* SuperKeyword */ - || kind === 197 /* NonNullExpression */; + || kind === 200 /* NonNullExpression */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 186 /* PrefixUnaryExpression */ - || kind === 187 /* PostfixUnaryExpression */ - || kind === 182 /* DeleteExpression */ - || kind === 183 /* TypeOfExpression */ - || kind === 184 /* VoidExpression */ - || kind === 185 /* AwaitExpression */ - || kind === 178 /* TypeAssertionExpression */ + return kind === 189 /* PrefixUnaryExpression */ + || kind === 190 /* PostfixUnaryExpression */ + || kind === 185 /* DeleteExpression */ + || kind === 186 /* TypeOfExpression */ + || kind === 187 /* VoidExpression */ + || kind === 188 /* AwaitExpression */ + || kind === 181 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -9707,13 +10050,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 189 /* ConditionalExpression */ - || kind === 191 /* YieldExpression */ - || kind === 181 /* ArrowFunction */ - || kind === 188 /* BinaryExpression */ - || kind === 192 /* SpreadElementExpression */ - || kind === 196 /* AsExpression */ - || kind === 194 /* OmittedExpression */ + return kind === 192 /* ConditionalExpression */ + || kind === 194 /* YieldExpression */ + || kind === 184 /* ArrowFunction */ + || kind === 191 /* BinaryExpression */ + || kind === 195 /* SpreadElement */ + || kind === 199 /* AsExpression */ + || kind === 197 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -9722,16 +10065,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 178 /* TypeAssertionExpression */ - || kind === 196 /* AsExpression */; + return kind === 181 /* TypeAssertionExpression */ + || kind === 199 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 288 /* PartiallyEmittedExpression */; + return node.kind === 292 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 287 /* NotEmittedStatement */; + return node.kind === 291 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9740,17 +10083,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 194 /* OmittedExpression */; + return node.kind === 197 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 198 /* TemplateSpan */; + return node.kind === 201 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 200 /* Block */; + return node.kind === 203 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -9768,119 +10111,121 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 219 /* VariableDeclaration */; + return node.kind === 222 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 220 /* VariableDeclarationList */; + return node.kind === 223 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 228 /* CaseBlock */; + return node.kind === 231 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 227 /* ModuleBlock */ - || kind === 226 /* ModuleDeclaration */; + return kind === 230 /* ModuleBlock */ + || kind === 229 /* ModuleDeclaration */; } ts.isModuleBody = isModuleBody; function isImportEqualsDeclaration(node) { - return node.kind === 230 /* ImportEqualsDeclaration */; + return node.kind === 233 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 232 /* ImportClause */; + return node.kind === 235 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 234 /* NamedImports */ - || kind === 233 /* NamespaceImport */; + return kind === 237 /* NamedImports */ + || kind === 236 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 235 /* ImportSpecifier */; + return node.kind === 238 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 238 /* NamedExports */; + return node.kind === 241 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 239 /* ExportSpecifier */; + return node.kind === 242 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 226 /* ModuleDeclaration */ || node.kind === 225 /* EnumDeclaration */; + return node.kind === 229 /* ModuleDeclaration */ || node.kind === 228 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 181 /* ArrowFunction */ - || kind === 170 /* BindingElement */ - || kind === 222 /* ClassDeclaration */ - || kind === 193 /* ClassExpression */ - || kind === 149 /* Constructor */ - || kind === 225 /* EnumDeclaration */ - || kind === 255 /* EnumMember */ - || kind === 239 /* ExportSpecifier */ - || kind === 221 /* FunctionDeclaration */ - || kind === 180 /* FunctionExpression */ - || kind === 150 /* GetAccessor */ - || kind === 232 /* ImportClause */ - || kind === 230 /* ImportEqualsDeclaration */ - || kind === 235 /* ImportSpecifier */ - || kind === 223 /* InterfaceDeclaration */ - || kind === 148 /* MethodDeclaration */ - || kind === 147 /* MethodSignature */ - || kind === 226 /* ModuleDeclaration */ - || kind === 229 /* NamespaceExportDeclaration */ - || kind === 233 /* NamespaceImport */ - || kind === 143 /* Parameter */ - || kind === 253 /* PropertyAssignment */ - || kind === 146 /* PropertyDeclaration */ - || kind === 145 /* PropertySignature */ - || kind === 151 /* SetAccessor */ - || kind === 254 /* ShorthandPropertyAssignment */ - || kind === 224 /* TypeAliasDeclaration */ - || kind === 142 /* TypeParameter */ - || kind === 219 /* VariableDeclaration */ - || kind === 279 /* JSDocTypedefTag */; + return kind === 184 /* ArrowFunction */ + || kind === 173 /* BindingElement */ + || kind === 225 /* ClassDeclaration */ + || kind === 196 /* ClassExpression */ + || kind === 150 /* Constructor */ + || kind === 228 /* EnumDeclaration */ + || kind === 259 /* EnumMember */ + || kind === 242 /* ExportSpecifier */ + || kind === 224 /* FunctionDeclaration */ + || kind === 183 /* FunctionExpression */ + || kind === 151 /* GetAccessor */ + || kind === 235 /* ImportClause */ + || kind === 233 /* ImportEqualsDeclaration */ + || kind === 238 /* ImportSpecifier */ + || kind === 226 /* InterfaceDeclaration */ + || kind === 149 /* MethodDeclaration */ + || kind === 148 /* MethodSignature */ + || kind === 229 /* ModuleDeclaration */ + || kind === 232 /* NamespaceExportDeclaration */ + || kind === 236 /* NamespaceImport */ + || kind === 144 /* Parameter */ + || kind === 256 /* PropertyAssignment */ + || kind === 147 /* PropertyDeclaration */ + || kind === 146 /* PropertySignature */ + || kind === 152 /* SetAccessor */ + || kind === 257 /* ShorthandPropertyAssignment */ + || kind === 227 /* TypeAliasDeclaration */ + || kind === 143 /* TypeParameter */ + || kind === 222 /* VariableDeclaration */ + || kind === 283 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 221 /* FunctionDeclaration */ - || kind === 240 /* MissingDeclaration */ - || kind === 222 /* ClassDeclaration */ - || kind === 223 /* InterfaceDeclaration */ - || kind === 224 /* TypeAliasDeclaration */ - || kind === 225 /* EnumDeclaration */ - || kind === 226 /* ModuleDeclaration */ - || kind === 231 /* ImportDeclaration */ - || kind === 230 /* ImportEqualsDeclaration */ - || kind === 237 /* ExportDeclaration */ - || kind === 236 /* ExportAssignment */ - || kind === 229 /* NamespaceExportDeclaration */; + return kind === 224 /* FunctionDeclaration */ + || kind === 243 /* MissingDeclaration */ + || kind === 225 /* ClassDeclaration */ + || kind === 226 /* InterfaceDeclaration */ + || kind === 227 /* TypeAliasDeclaration */ + || kind === 228 /* EnumDeclaration */ + || kind === 229 /* ModuleDeclaration */ + || kind === 234 /* ImportDeclaration */ + || kind === 233 /* ImportEqualsDeclaration */ + || kind === 240 /* ExportDeclaration */ + || kind === 239 /* ExportAssignment */ + || kind === 232 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 211 /* BreakStatement */ - || kind === 210 /* ContinueStatement */ - || kind === 218 /* DebuggerStatement */ - || kind === 205 /* DoStatement */ - || kind === 203 /* ExpressionStatement */ - || kind === 202 /* EmptyStatement */ - || kind === 208 /* ForInStatement */ - || kind === 209 /* ForOfStatement */ - || kind === 207 /* ForStatement */ - || kind === 204 /* IfStatement */ - || kind === 215 /* LabeledStatement */ - || kind === 212 /* ReturnStatement */ - || kind === 214 /* SwitchStatement */ - || kind === 216 /* ThrowStatement */ - || kind === 217 /* TryStatement */ - || kind === 201 /* VariableStatement */ - || kind === 206 /* WhileStatement */ - || kind === 213 /* WithStatement */ - || kind === 287 /* NotEmittedStatement */; + return kind === 214 /* BreakStatement */ + || kind === 213 /* ContinueStatement */ + || kind === 221 /* DebuggerStatement */ + || kind === 208 /* DoStatement */ + || kind === 206 /* ExpressionStatement */ + || kind === 205 /* EmptyStatement */ + || kind === 211 /* ForInStatement */ + || kind === 212 /* ForOfStatement */ + || kind === 210 /* ForStatement */ + || kind === 207 /* IfStatement */ + || kind === 218 /* LabeledStatement */ + || kind === 215 /* ReturnStatement */ + || kind === 217 /* SwitchStatement */ + || kind === 219 /* ThrowStatement */ + || kind === 220 /* TryStatement */ + || kind === 204 /* VariableStatement */ + || kind === 209 /* WhileStatement */ + || kind === 216 /* WithStatement */ + || kind === 291 /* NotEmittedStatement */ + || kind === 294 /* EndOfDeclarationMarker */ + || kind === 293 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -9901,93 +10246,93 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 200 /* Block */; + || kind === 203 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 241 /* ExternalModuleReference */ - || kind === 140 /* QualifiedName */ + return kind === 244 /* ExternalModuleReference */ + || kind === 141 /* QualifiedName */ || kind === 70 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 244 /* JsxOpeningElement */; + return node.kind === 247 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 245 /* JsxClosingElement */; + return node.kind === 248 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; return kind === 98 /* ThisKeyword */ || kind === 70 /* Identifier */ - || kind === 173 /* PropertyAccessExpression */; + || kind === 176 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 242 /* JsxElement */ - || kind === 248 /* JsxExpression */ - || kind === 243 /* JsxSelfClosingElement */ + return kind === 245 /* JsxElement */ + || kind === 251 /* JsxExpression */ + || kind === 246 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 246 /* JsxAttribute */ - || kind === 247 /* JsxSpreadAttribute */; + return kind === 249 /* JsxAttribute */ + || kind === 250 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 247 /* JsxSpreadAttribute */; + return node.kind === 250 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 246 /* JsxAttribute */; + return node.kind === 249 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 248 /* JsxExpression */; + || kind === 251 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 249 /* CaseClause */ - || kind === 250 /* DefaultClause */; + return kind === 252 /* CaseClause */ + || kind === 253 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 251 /* HeritageClause */; + return node.kind === 254 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 252 /* CatchClause */; + return node.kind === 255 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 253 /* PropertyAssignment */; + return node.kind === 256 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 254 /* ShorthandPropertyAssignment */; + return node.kind === 257 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 259 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 256 /* SourceFile */; + return node.kind === 260 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -9999,6 +10344,7 @@ var ts; (function (ts) { function getDefaultLibFileName(options) { switch (options.target) { + case 5 /* ESNext */: case 4 /* ES2017 */: return "lib.es2017.d.ts"; case 3 /* ES2016 */: @@ -10216,9 +10562,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 142 /* TypeParameter */) { + if (d && d.kind === 143 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 226 /* InterfaceDeclaration */) { return current; } } @@ -10226,11 +10572,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 149 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 150 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 170 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 173 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10238,14 +10584,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 223 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 204 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10261,14 +10607,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 220 /* VariableDeclarationList */) { + if (node && node.kind === 223 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 201 /* VariableStatement */) { + if (node && node.kind === 204 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -10283,7 +10629,7 @@ var ts; var NodeConstructor; var SourceFileConstructor; function createNode(kind, location, flags) { - var ConstructorForKind = kind === 256 /* SourceFile */ + var ConstructorForKind = kind === 260 /* SourceFile */ ? (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor())) : (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor())); var node = location @@ -10466,7 +10812,7 @@ var ts; ts.createNull = createNull; // Names function createComputedPropertyName(expression, location) { - var node = createNode(141 /* ComputedPropertyName */, location); + var node = createNode(142 /* ComputedPropertyName */, location); node.expression = expression; return node; } @@ -10479,17 +10825,8 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements - function createParameter(name, initializer, location) { - return createParameterDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, name, - /*questionToken*/ undefined, - /*type*/ undefined, initializer, location); - } - ts.createParameter = createParameter; - function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { - var node = createNode(143 /* Parameter */, location, flags); + function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer, location, flags) { + var node = createNode(144 /* Parameter */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.dotDotDotToken = dotDotDotToken; @@ -10499,17 +10836,17 @@ var ts; node.initializer = initializer ? parenthesizeExpressionForList(initializer) : undefined; return node; } - ts.createParameterDeclaration = createParameterDeclaration; - function updateParameterDeclaration(node, decorators, modifiers, name, type, initializer) { + ts.createParameter = createParameter; + function updateParameter(node, decorators, modifiers, name, type, initializer) { if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameterDeclaration(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); + return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, /*location*/ node, /*flags*/ node.flags), node); } return node; } - ts.updateParameterDeclaration = updateParameterDeclaration; + ts.updateParameter = updateParameter; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer, location) { - var node = createNode(146 /* PropertyDeclaration */, location); + var node = createNode(147 /* PropertyDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10527,7 +10864,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(148 /* MethodDeclaration */, location, flags); + var node = createNode(149 /* MethodDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -10547,7 +10884,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body, location, flags) { - var node = createNode(149 /* Constructor */, location, flags); + var node = createNode(150 /* Constructor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = undefined; @@ -10565,7 +10902,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body, location, flags) { - var node = createNode(150 /* GetAccessor */, location, flags); + var node = createNode(151 /* GetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10584,7 +10921,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body, location, flags) { - var node = createNode(151 /* SetAccessor */, location, flags); + var node = createNode(152 /* SetAccessor */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10603,7 +10940,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements, location) { - var node = createNode(168 /* ObjectBindingPattern */, location); + var node = createNode(171 /* ObjectBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10616,7 +10953,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements, location) { - var node = createNode(169 /* ArrayBindingPattern */, location); + var node = createNode(172 /* ArrayBindingPattern */, location); node.elements = createNodeArray(elements); return node; } @@ -10629,7 +10966,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(propertyName, dotDotDotToken, name, initializer, location) { - var node = createNode(170 /* BindingElement */, location); + var node = createNode(173 /* BindingElement */, location); node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; node.dotDotDotToken = dotDotDotToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10646,7 +10983,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, location, multiLine) { - var node = createNode(171 /* ArrayLiteralExpression */, location); + var node = createNode(174 /* ArrayLiteralExpression */, location); node.elements = parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10662,7 +10999,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, location, multiLine) { - var node = createNode(172 /* ObjectLiteralExpression */, location); + var node = createNode(175 /* ObjectLiteralExpression */, location); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10678,7 +11015,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name, location, flags) { - var node = createNode(173 /* PropertyAccessExpression */, location, flags); + var node = createNode(176 /* PropertyAccessExpression */, location, flags); node.expression = parenthesizeForAccess(expression); (node.emitNode || (node.emitNode = {})).flags |= 1048576 /* NoIndentation */; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10696,7 +11033,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index, location) { - var node = createNode(174 /* ElementAccessExpression */, location); + var node = createNode(177 /* ElementAccessExpression */, location); node.expression = parenthesizeForAccess(expression); node.argumentExpression = typeof index === "number" ? createLiteral(index) : index; return node; @@ -10710,7 +11047,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(175 /* CallExpression */, location, flags); + var node = createNode(178 /* CallExpression */, location, flags); node.expression = parenthesizeForAccess(expression); if (typeArguments) { node.typeArguments = createNodeArray(typeArguments); @@ -10727,7 +11064,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray, location, flags) { - var node = createNode(176 /* NewExpression */, location, flags); + var node = createNode(179 /* NewExpression */, location, flags); node.expression = parenthesizeForNew(expression); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.arguments = argumentsArray ? parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10742,7 +11079,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template, location) { - var node = createNode(177 /* TaggedTemplateExpression */, location); + var node = createNode(180 /* TaggedTemplateExpression */, location); node.tag = parenthesizeForAccess(tag); node.template = template; return node; @@ -10756,7 +11093,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createParen(expression, location) { - var node = createNode(179 /* ParenthesizedExpression */, location); + var node = createNode(182 /* ParenthesizedExpression */, location); node.expression = expression; return node; } @@ -10769,7 +11106,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(180 /* FunctionExpression */, location, flags); + var node = createNode(183 /* FunctionExpression */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; node.name = typeof name === "string" ? createIdentifier(name) : name; @@ -10788,7 +11125,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body, location, flags) { - var node = createNode(181 /* ArrowFunction */, location, flags); + var node = createNode(184 /* ArrowFunction */, location, flags); node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined; node.parameters = createNodeArray(parameters); @@ -10806,7 +11143,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression, location) { - var node = createNode(182 /* DeleteExpression */, location); + var node = createNode(185 /* DeleteExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10819,7 +11156,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression, location) { - var node = createNode(183 /* TypeOfExpression */, location); + var node = createNode(186 /* TypeOfExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10832,7 +11169,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression, location) { - var node = createNode(184 /* VoidExpression */, location); + var node = createNode(187 /* VoidExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10845,7 +11182,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression, location) { - var node = createNode(185 /* AwaitExpression */, location); + var node = createNode(188 /* AwaitExpression */, location); node.expression = parenthesizePrefixOperand(expression); return node; } @@ -10858,7 +11195,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand, location) { - var node = createNode(186 /* PrefixUnaryExpression */, location); + var node = createNode(189 /* PrefixUnaryExpression */, location); node.operator = operator; node.operand = parenthesizePrefixOperand(operand); return node; @@ -10872,7 +11209,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator, location) { - var node = createNode(187 /* PostfixUnaryExpression */, location); + var node = createNode(190 /* PostfixUnaryExpression */, location); node.operand = parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10888,7 +11225,7 @@ var ts; function createBinary(left, operator, right, location) { var operatorToken = typeof operator === "number" ? createToken(operator) : operator; var operatorKind = operatorToken.kind; - var node = createNode(188 /* BinaryExpression */, location); + var node = createNode(191 /* BinaryExpression */, location); node.left = parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); node.operatorToken = operatorToken; node.right = parenthesizeBinaryOperand(operatorKind, right, /*isLeftSideOfBinary*/ false, node.left); @@ -10903,7 +11240,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(189 /* ConditionalExpression */, location); + var node = createNode(192 /* ConditionalExpression */, location); node.condition = condition; node.questionToken = questionToken; node.whenTrue = whenTrue; @@ -10920,7 +11257,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans, location) { - var node = createNode(190 /* TemplateExpression */, location); + var node = createNode(193 /* TemplateExpression */, location); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -10934,7 +11271,7 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskToken, expression, location) { - var node = createNode(191 /* YieldExpression */, location); + var node = createNode(194 /* YieldExpression */, location); node.asteriskToken = asteriskToken; node.expression = expression; return node; @@ -10948,7 +11285,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression, location) { - var node = createNode(192 /* SpreadElementExpression */, location); + var node = createNode(195 /* SpreadElement */, location); node.expression = parenthesizeExpressionForList(expression); return node; } @@ -10961,7 +11298,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(193 /* ClassExpression */, location); + var node = createNode(196 /* ClassExpression */, location); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -10979,12 +11316,12 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression(location) { - var node = createNode(194 /* OmittedExpression */, location); + var node = createNode(197 /* OmittedExpression */, location); return node; } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression, location) { - var node = createNode(195 /* ExpressionWithTypeArguments */, location); + var node = createNode(198 /* ExpressionWithTypeArguments */, location); node.typeArguments = typeArguments ? createNodeArray(typeArguments) : undefined; node.expression = parenthesizeForAccess(expression); return node; @@ -10999,7 +11336,7 @@ var ts; ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; // Misc function createTemplateSpan(expression, literal, location) { - var node = createNode(198 /* TemplateSpan */, location); + var node = createNode(201 /* TemplateSpan */, location); node.expression = expression; node.literal = literal; return node; @@ -11014,7 +11351,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, location, multiLine, flags) { - var block = createNode(200 /* Block */, location, flags); + var block = createNode(203 /* Block */, location, flags); block.statements = createNodeArray(statements); if (multiLine) { block.multiLine = true; @@ -11030,7 +11367,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList, location, flags) { - var node = createNode(201 /* VariableStatement */, location, flags); + var node = createNode(204 /* VariableStatement */, location, flags); node.decorators = undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11045,7 +11382,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, location, flags) { - var node = createNode(220 /* VariableDeclarationList */, location, flags); + var node = createNode(223 /* VariableDeclarationList */, location, flags); node.declarations = createNodeArray(declarations); return node; } @@ -11058,7 +11395,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer, location, flags) { - var node = createNode(219 /* VariableDeclaration */, location, flags); + var node = createNode(222 /* VariableDeclaration */, location, flags); node.name = typeof name === "string" ? createIdentifier(name) : name; node.type = type; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11073,11 +11410,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement(location) { - return createNode(202 /* EmptyStatement */, location); + return createNode(205 /* EmptyStatement */, location); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression, location, flags) { - var node = createNode(203 /* ExpressionStatement */, location, flags); + var node = createNode(206 /* ExpressionStatement */, location, flags); node.expression = parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11090,7 +11427,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement, location) { - var node = createNode(204 /* IfStatement */, location); + var node = createNode(207 /* IfStatement */, location); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11105,7 +11442,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression, location) { - var node = createNode(205 /* DoStatement */, location); + var node = createNode(208 /* DoStatement */, location); node.statement = statement; node.expression = expression; return node; @@ -11119,7 +11456,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement, location) { - var node = createNode(206 /* WhileStatement */, location); + var node = createNode(209 /* WhileStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11133,7 +11470,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement, location) { - var node = createNode(207 /* ForStatement */, location, /*flags*/ undefined); + var node = createNode(210 /* ForStatement */, location, /*flags*/ undefined); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11149,7 +11486,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement, location) { - var node = createNode(208 /* ForInStatement */, location); + var node = createNode(211 /* ForInStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11164,7 +11501,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(initializer, expression, statement, location) { - var node = createNode(209 /* ForOfStatement */, location); + var node = createNode(212 /* ForOfStatement */, location); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11179,7 +11516,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label, location) { - var node = createNode(210 /* ContinueStatement */, location); + var node = createNode(213 /* ContinueStatement */, location); if (label) { node.label = label; } @@ -11194,7 +11531,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label, location) { - var node = createNode(211 /* BreakStatement */, location); + var node = createNode(214 /* BreakStatement */, location); if (label) { node.label = label; } @@ -11209,7 +11546,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression, location) { - var node = createNode(212 /* ReturnStatement */, location); + var node = createNode(215 /* ReturnStatement */, location); node.expression = expression; return node; } @@ -11222,7 +11559,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement, location) { - var node = createNode(213 /* WithStatement */, location); + var node = createNode(216 /* WithStatement */, location); node.expression = expression; node.statement = statement; return node; @@ -11236,7 +11573,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock, location) { - var node = createNode(214 /* SwitchStatement */, location); + var node = createNode(217 /* SwitchStatement */, location); node.expression = parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11250,7 +11587,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement, location) { - var node = createNode(215 /* LabeledStatement */, location); + var node = createNode(218 /* LabeledStatement */, location); node.label = typeof label === "string" ? createIdentifier(label) : label; node.statement = statement; return node; @@ -11264,7 +11601,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression, location) { - var node = createNode(216 /* ThrowStatement */, location); + var node = createNode(219 /* ThrowStatement */, location); node.expression = expression; return node; } @@ -11277,7 +11614,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock, location) { - var node = createNode(217 /* TryStatement */, location); + var node = createNode(220 /* TryStatement */, location); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11292,7 +11629,7 @@ var ts; } ts.updateTry = updateTry; function createCaseBlock(clauses, location) { - var node = createNode(228 /* CaseBlock */, location); + var node = createNode(231 /* CaseBlock */, location); node.clauses = createNodeArray(clauses); return node; } @@ -11305,7 +11642,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body, location, flags) { - var node = createNode(221 /* FunctionDeclaration */, location, flags); + var node = createNode(224 /* FunctionDeclaration */, location, flags); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.asteriskToken = asteriskToken; @@ -11325,7 +11662,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members, location) { - var node = createNode(222 /* ClassDeclaration */, location); + var node = createNode(225 /* ClassDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.name = name; @@ -11343,7 +11680,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, location) { - var node = createNode(231 /* ImportDeclaration */, location); + var node = createNode(234 /* ImportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.importClause = importClause; @@ -11359,7 +11696,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings, location) { - var node = createNode(232 /* ImportClause */, location); + var node = createNode(235 /* ImportClause */, location); node.name = name; node.namedBindings = namedBindings; return node; @@ -11373,7 +11710,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name, location) { - var node = createNode(233 /* NamespaceImport */, location); + var node = createNode(236 /* NamespaceImport */, location); node.name = name; return node; } @@ -11386,7 +11723,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements, location) { - var node = createNode(234 /* NamedImports */, location); + var node = createNode(237 /* NamedImports */, location); node.elements = createNodeArray(elements); return node; } @@ -11399,7 +11736,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name, location) { - var node = createNode(235 /* ImportSpecifier */, location); + var node = createNode(238 /* ImportSpecifier */, location); node.propertyName = propertyName; node.name = name; return node; @@ -11413,7 +11750,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression, location) { - var node = createNode(236 /* ExportAssignment */, location); + var node = createNode(239 /* ExportAssignment */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.isExportEquals = isExportEquals; @@ -11429,7 +11766,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier, location) { - var node = createNode(237 /* ExportDeclaration */, location); + var node = createNode(240 /* ExportDeclaration */, location); node.decorators = decorators ? createNodeArray(decorators) : undefined; node.modifiers = modifiers ? createNodeArray(modifiers) : undefined; node.exportClause = exportClause; @@ -11445,7 +11782,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements, location) { - var node = createNode(238 /* NamedExports */, location); + var node = createNode(241 /* NamedExports */, location); node.elements = createNodeArray(elements); return node; } @@ -11458,7 +11795,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(name, propertyName, location) { - var node = createNode(239 /* ExportSpecifier */, location); + var node = createNode(242 /* ExportSpecifier */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.propertyName = typeof propertyName === "string" ? createIdentifier(propertyName) : propertyName; return node; @@ -11473,7 +11810,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // JSX function createJsxElement(openingElement, children, closingElement, location) { - var node = createNode(242 /* JsxElement */, location); + var node = createNode(245 /* JsxElement */, location); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11488,7 +11825,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes, location) { - var node = createNode(243 /* JsxSelfClosingElement */, location); + var node = createNode(246 /* JsxSelfClosingElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11502,7 +11839,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes, location) { - var node = createNode(244 /* JsxOpeningElement */, location); + var node = createNode(247 /* JsxOpeningElement */, location); node.tagName = tagName; node.attributes = createNodeArray(attributes); return node; @@ -11516,7 +11853,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName, location) { - var node = createNode(245 /* JsxClosingElement */, location); + var node = createNode(248 /* JsxClosingElement */, location); node.tagName = tagName; return node; } @@ -11529,7 +11866,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttribute(name, initializer, location) { - var node = createNode(246 /* JsxAttribute */, location); + var node = createNode(249 /* JsxAttribute */, location); node.name = name; node.initializer = initializer; return node; @@ -11543,7 +11880,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression, location) { - var node = createNode(247 /* JsxSpreadAttribute */, location); + var node = createNode(250 /* JsxSpreadAttribute */, location); node.expression = expression; return node; } @@ -11556,7 +11893,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(expression, location) { - var node = createNode(248 /* JsxExpression */, location); + var node = createNode(251 /* JsxExpression */, location); node.expression = expression; return node; } @@ -11570,7 +11907,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types, location) { - var node = createNode(251 /* HeritageClause */, location); + var node = createNode(254 /* HeritageClause */, location); node.token = token; node.types = createNodeArray(types); return node; @@ -11584,7 +11921,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements, location) { - var node = createNode(249 /* CaseClause */, location); + var node = createNode(252 /* CaseClause */, location); node.expression = parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11598,7 +11935,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements, location) { - var node = createNode(250 /* DefaultClause */, location); + var node = createNode(253 /* DefaultClause */, location); node.statements = createNodeArray(statements); return node; } @@ -11611,7 +11948,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block, location) { - var node = createNode(252 /* CatchClause */, location); + var node = createNode(255 /* CatchClause */, location); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11626,7 +11963,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer, location) { - var node = createNode(253 /* PropertyAssignment */, location); + var node = createNode(256 /* PropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.questionToken = undefined; node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; @@ -11641,12 +11978,18 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer, location) { - var node = createNode(254 /* ShorthandPropertyAssignment */, location); + var node = createNode(257 /* ShorthandPropertyAssignment */, location); node.name = typeof name === "string" ? createIdentifier(name) : name; node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; + function createSpreadAssignment(expression, location) { + var node = createNode(258 /* SpreadAssignment */, location); + node.expression = expression !== undefined ? parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer, node), node); @@ -11654,10 +11997,17 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function updateSpreadAssignment(node, expression) { + if (node.expression !== expression) { + return updateNode(createSpreadAssignment(expression, node), node); + } + return node; + } + ts.updateSpreadAssignment = updateSpreadAssignment; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createNode(256 /* SourceFile */, /*location*/ node, node.flags); + var updated = createNode(260 /* SourceFile */, /*location*/ node, node.flags); updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; updated.fileName = node.fileName; @@ -11726,11 +12076,33 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createNode(287 /* NotEmittedStatement */, /*location*/ original); + var node = createNode(291 /* NotEmittedStatement */, /*location*/ original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; + /** + * Creates a synthetic element to act as a placeholder for the end of an emitted declaration in + * order to properly emit exports. + */ + function createEndOfDeclarationMarker(original) { + var node = createNode(294 /* EndOfDeclarationMarker */); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; + /** + * Creates a synthetic element to act as a placeholder for the beginning of a merged declaration in + * order to properly emit exports. + */ + function createMergeDeclarationMarker(original) { + var node = createNode(293 /* MergeDeclarationMarker */); + node.emitNode = {}; + node.original = original; + return node; + } + ts.createMergeDeclarationMarker = createMergeDeclarationMarker; /** * Creates a synthetic expression to act as a placeholder for a not-emitted expression in * order to preserve comments or sourcemap positions. @@ -11740,7 +12112,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(288 /* PartiallyEmittedExpression */, /*location*/ location || original); + var node = createNode(292 /* PartiallyEmittedExpression */, /*location*/ location || original); node.expression = expression; node.original = original; return node; @@ -11813,15 +12185,6 @@ var ts; } } ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName; - function createRestParameter(name) { - return createParameterDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, createToken(23 /* DotDotDotToken */), name, - /*questionToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); - } - ts.createRestParameter = createRestParameter; function createFunctionCall(func, thisArg, argumentsList, location) { return createCall(createPropertyAccess(func, "call"), /*typeArguments*/ undefined, [ @@ -11866,7 +12229,20 @@ var ts; react.parent = ts.getParseTreeNode(parent); return react; } - function createReactCreateElement(reactNamespace, tagName, props, children, parentElement, location) { + function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { + if (ts.isQualifiedName(jsxFactory)) { + return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536 /* NoSourceMap */)); + } + else { + return createReactNamespace(jsxFactory.text, parent); + } + } + function createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parent) { + return jsxFactoryEntity ? + createJsxFactoryExpressionFromEntityName(jsxFactoryEntity, parent) : + createPropertyAccess(createReactNamespace(reactNamespace, parent), "createElement"); + } + function createExpressionForJsxElement(jsxFactoryEntity, reactNamespace, tagName, props, children, parentElement, location) { var argumentsList = [tagName]; if (props) { argumentsList.push(props); @@ -11886,10 +12262,22 @@ var ts; argumentsList.push(children[0]); } } - return createCall(createPropertyAccess(createReactNamespace(reactNamespace, parentElement), "createElement"), + return createCall(createJsxFactoryExpression(jsxFactoryEntity, reactNamespace, parentElement), /*typeArguments*/ undefined, argumentsList, location); } - ts.createReactCreateElement = createReactCreateElement; + ts.createExpressionForJsxElement = createExpressionForJsxElement; + function createExportDefault(expression) { + return createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); + } + ts.createExportDefault = createExportDefault; + function createExternalModuleExport(exportName) { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + } + ts.createExternalModuleExport = createExternalModuleExport; + function createLetStatement(name, initializer, location) { + return createVariableStatement(/*modifiers*/ undefined, createLetDeclarationList([createVariableDeclaration(name, /*type*/ undefined, initializer)]), location); + } + ts.createLetStatement = createLetStatement; function createLetDeclarationList(declarations, location) { return createVariableDeclarationList(declarations, location, 1 /* Let */); } @@ -11978,20 +12366,18 @@ var ts; // name => super[name] return createArrowFunction( /*modifiers*/ undefined, - /*typeParameters*/ undefined, [createParameter("name")], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createElementAccess(target, createIdentifier("name"))); + /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name")], + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createElementAccess(target, createIdentifier("name"))); } function createSeti(target) { // (name, value) => super[name] = value return createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, [ - createParameter("name"), - createParameter("value") + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "value") ], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); } function createAdvancedAsyncSuperHelper() { // const _super = (function (geti, seti) { @@ -12016,7 +12402,7 @@ var ts; // set value(v) { seti(name, v); } var setter = createSetAccessor( /*decorators*/ undefined, - /*modifiers*/ undefined, "value", [createParameter("v")], createBlock([ + /*modifiers*/ undefined, "value", [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "v")], createBlock([ createStatement(createCall(createIdentifier("seti"), /*typeArguments*/ undefined, [ createIdentifier("name"), @@ -12026,9 +12412,8 @@ var ts; // return name => cache[name] || ... var getOrCreateAccessorsForName = createReturn(createArrowFunction( /*modifiers*/ undefined, - /*typeParameters*/ undefined, [createParameter("name")], - /*type*/ undefined, - /*equalsGreaterThanToken*/ undefined, createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ + /*typeParameters*/ undefined, [createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "name")], + /*type*/ undefined, createToken(35 /* EqualsGreaterThanToken */), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ getter, setter ])))))); @@ -12044,8 +12429,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, [ - createParameter("geti"), - createParameter("seti") + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "geti"), + createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "seti") ], /*type*/ undefined, createBlock([ createCache, @@ -12075,13 +12460,13 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -12101,7 +12486,7 @@ var ts; } else { switch (callee.kind) { - case 173 /* PropertyAccessExpression */: { + case 176 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12115,7 +12500,7 @@ var ts; } break; } - case 174 /* ElementAccessExpression */: { + case 177 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = createTempVariable(recordTempVariable); @@ -12169,14 +12554,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12240,6 +12625,112 @@ var ts; /*location*/ method), /*original*/ method)); } + /** + * Gets the local name of a declaration. This is primarily used for declarations that can be + * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A + * local name will *never* be prefixed with an module or namespace export modifier like + * "exports." when emitted as an expression. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); + } + ts.getLocalName = getLocalName; + /** + * Gets whether an identifier should only be referred to by its local name. + */ + function isLocalName(node) { + return (getEmitFlags(node) & 262144 /* LocalName */) !== 0; + } + ts.isLocalName = isLocalName; + /** + * Gets the export name of a declaration. This is primarily used for declarations that can be + * referred to by name in the declaration's immediate scope (classes, enums, namespaces). An + * export name will *always* be prefixed with an module or namespace export modifier like + * `"exports."` when emitted as an expression if the name points to an exported symbol. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExportName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 131072 /* ExportName */); + } + ts.getExportName = getExportName; + /** + * Gets whether an identifier should only be referred to by its export representation if the + * name points to an exported symbol. + */ + function isExportName(node) { + return (getEmitFlags(node) & 131072 /* ExportName */) !== 0; + } + ts.isExportName = isExportName; + /** + * Gets the name of a declaration for use in declarations. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getDeclarationName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps); + } + ts.getDeclarationName = getDeclarationName; + function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { + var name_11 = getMutableClone(node.name); + emitFlags |= getEmitFlags(node.name); + if (!allowSourceMaps) + emitFlags |= 1536 /* NoSourceMap */; + if (!allowComments) + emitFlags |= 49152 /* NoComments */; + if (emitFlags) + setEmitFlags(name_11, emitFlags); + return name_11; + } + return getGeneratedNameForNode(node); + } + /** + * Gets the exported name of a declaration for use in expressions. + * + * An exported name will *always* be prefixed with an module or namespace export modifier like + * "exports." if the name points to an exported symbol. + * + * @param ns The namespace identifier. + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { + if (ns && ts.hasModifier(node, 1 /* Export */)) { + return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); + } + return getExportName(node, allowComments, allowSourceMaps); + } + ts.getExternalModuleOrNamespaceExportName = getExternalModuleOrNamespaceExportName; + /** + * Gets a namespace-qualified name for use in expressions. + * + * @param ns The namespace identifier. + * @param name The name. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { + var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), /*location*/ name); + var emitFlags; + if (!allowSourceMaps) + emitFlags |= 1536 /* NoSourceMap */; + if (!allowComments) + emitFlags |= 49152 /* NoComments */; + if (emitFlags) + setEmitFlags(qualifiedName, emitFlags); + return qualifiedName; + } + ts.getNamespaceMemberName = getNamespaceMemberName; // Utilities function isUseStrictPrologue(node) { return node.expression.text === "use strict"; @@ -12329,7 +12820,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 179 /* ParenthesizedExpression */) { + if (skipped.kind === 182 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12363,8 +12854,8 @@ 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(188 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(188 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(191 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(191 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -12373,7 +12864,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 191 /* YieldExpression */) { + && operand.kind === 194 /* YieldExpression */) { return false; } return true; @@ -12461,7 +12952,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12484,9 +12975,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return createParen(expression); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return emittedExpression.arguments ? expression : createParen(expression); @@ -12511,7 +13002,7 @@ var ts; // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 176 /* NewExpression */ || emittedExpression.arguments) + && (emittedExpression.kind !== 179 /* NewExpression */ || emittedExpression.arguments) && emittedExpression.kind !== 8 /* NumericLiteral */) { return expression; } @@ -12549,7 +13040,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(188 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(191 /* BinaryExpression */, 25 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : createParen(expression, /*location*/ expression); @@ -12560,7 +13051,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 180 /* FunctionExpression */ || kind === 181 /* ArrowFunction */) { + if (kind === 183 /* FunctionExpression */ || kind === 184 /* ArrowFunction */) { var mutableCall = getMutableClone(emittedExpression); mutableCall.expression = createParen(callee, /*location*/ callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12568,7 +13059,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 172 /* ObjectLiteralExpression */ || leftmostExpressionKind === 180 /* FunctionExpression */) { + if (leftmostExpressionKind === 175 /* ObjectLiteralExpression */ || leftmostExpressionKind === 183 /* FunctionExpression */) { return createParen(expression, /*location*/ expression); } } @@ -12592,21 +13083,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: node = node.operand; continue; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: node = node.left; continue; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: node = node.condition; continue; - case 175 /* CallExpression */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 178 /* CallExpression */: + case 177 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: node = node.expression; continue; - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -12615,19 +13106,19 @@ var ts; } function parenthesizeConciseBody(body) { var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 172 /* ObjectLiteralExpression */) { + if (emittedBody.kind === 175 /* ObjectLiteralExpression */) { return createParen(body, /*location*/ body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; + var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; - })(ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); - var OuterExpressionKinds = ts.OuterExpressionKinds; + })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); function skipOuterExpressions(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } var previousNode; @@ -12647,7 +13138,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */) { + while (node.kind === 182 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -12661,7 +13152,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 288 /* PartiallyEmittedExpression */) { + while (node.kind === 292 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -12736,7 +13227,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 === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12878,13 +13369,13 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_9 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_9) ? name_9 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_12 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_12) ? name_12 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 231 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 234 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 237 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 240 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } return undefined; @@ -12941,6 +13432,363 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } + /** + * Transforms the body of a function-like node. + * + * @param node A function-like node. + */ + function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { + var multiLine = false; // indicates whether the block *must* be emitted as multiple lines + var singleLine = false; // indicates whether the block *may* be emitted as a single line + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + context.startLexicalEnvironment(); + if (ts.isBlock(body)) { + // ensureUseStrict is false because no new prologue-directive should be added. + // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array + statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); + addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); + addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); + // If we added any generated statements, this must be a multi-line block. + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + // If the original body was a multi-line block, this must be a multi-line block. + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 184 /* 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 + // being emitted for the end position only. + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = createReturn(expression, /*location*/ body); + setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); + statements.push(returnStatement); + // To align with the source map emit for the old emitter, we set a custom + // source map location for the close brace. + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + // If we added any final generated statements, this must be a multi-line block + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + setEmitFlags(block, 32 /* SingleLine */); + } + if (closeBraceLocation) { + setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + } + setOriginalNode(block, node.body); + return block; + } + ts.transformFunctionBody = transformFunctionBody; + /** + * Adds a statement to capture the `this` of a function declaration if it is needed. + * + * @param statements The statements for the new function body. + * @param node A node. + */ + function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { + if (node.transformFlags & 524288 /* ContainsCapturedLexicalThis */ && node.kind !== 184 /* ArrowFunction */) { + captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + } + } + ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; + function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration("_this", + /*type*/ undefined, initializer) + ]), originalStatement); + setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); + setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } + ts.captureThisForNode = captureThisForNode; + /** + * Gets a value indicating whether we need to add default value assignments for a + * function-like node. + * + * @param node A function-like node. + */ + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 2097152 /* ContainsDefaultValueAssignments */) !== 0; + } + /** + * Adds statements to the body of a function-like node if it contains parameters with + * binding patterns or initializers. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + */ + function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + var name_13 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_13)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_13, initializer, visitor, convertObjectRest); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_13, initializer, visitor); + } + } + } + ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; + /** + * Adds statements to the body of a function-like node for parameters with binding patterns + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { + var temp = getGeneratedNameForNode(parameter); + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + if (name.elements.length > 0) { + statements.push(setEmitFlags(createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608 /* CustomPrologue */)); + } + else if (initializer) { + statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); + } + } + /** + * Adds statements to the body of a function-like node for parameters with initializers. + * + * @param statements The statements for the new function body. + * @param parameter The parameter for the function. + * @param name The name of the parameter. + * @param initializer The initializer for the parameter. + */ + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ + createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536 /* NoSourceMap */), setEmitFlags(initializer, 1536 /* NoSourceMap */ | getEmitFlags(initializer)), + /*location*/ parameter)) + ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), + /*elseStatement*/ undefined, + /*location*/ parameter); + statement.startsOnNewLine = true; + setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); + statements.push(statement); + } + /** + * Gets a value indicating whether we need to add statements to handle a rest parameter. + * + * @param node A ParameterDeclaration node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + } + /** + * Adds statements to the body of a function-like node if it contains a rest parameter. + * + * @param statements The statements for the new function body. + * @param node A function-like node. + * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is + * part of a constructor declaration with a + * synthesized call to `super` + */ + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + // `declarationName` is the name of the local declaration for the parameter. + var declarationName = getMutableClone(parameter.name); + setEmitFlags(declarationName, 1536 /* NoSourceMap */); + // `expressionName` is the name of the parameter used in expressions. + var expressionName = getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = createLoopVariable(); + // var param = []; + statements.push(setEmitFlags(createVariableStatement( + /*modifiers*/ undefined, createVariableDeclarationList([ + createVariableDeclaration(declarationName, + /*type*/ undefined, createArrayLiteral([])) + ]), + /*location*/ parameter), 8388608 /* CustomPrologue */)); + // for (var _i = restIndex; _i < arguments.length; _i++) { + // param[_i - restIndex] = arguments[_i]; + // } + var forStatement = createFor(createVariableDeclarationList([ + createVariableDeclaration(temp, /*type*/ undefined, createLiteral(restIndex)) + ], /*location*/ parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), + /*location*/ parameter), createPostfixIncrement(temp, /*location*/ parameter), createBlock([ + startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), + /*location*/ parameter)) + ])); + setEmitFlags(forStatement, 8388608 /* CustomPrologue */); + startOnNewLine(forStatement); + statements.push(forStatement); + } + ts.addRestParameterIfNeeded = addRestParameterIfNeeded; + function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { + // The following ES6 code: + // + // for (let v of expr) { } + // + // should be emitted as + // + // for (var _i = 0, _a = expr; _i < _a.length; _i++) { + // var v = _a[_i]; + // } + // + // where _a and _i are temps emitted to capture the RHS and the counter, + // respectively. + // When the left hand side is an expression instead of a let declaration, + // the "let v" is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + // In the case where the user wrote an identifier as the RHS, like this: + // + // for (let v of arr) { } + // + // we don't want to emit a temporary variable for the RHS, just use it directly. + var counter = convertObjectRest ? undefined : createLoopVariable(); + var rhsReference = expression.kind === 70 /* Identifier */ + ? createUniqueName(expression.text) + : createTempVariable(/*recordTempVariable*/ undefined); + var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); + // Initialize LHS + // var v = _a[_i]; + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, + /*recordTempVariable*/ undefined, convertObjectRest); + var declarationList = createVariableDeclarationList(declarations, /*location*/ initializer); + setOriginalNode(declarationList, initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(createVariableStatement( + /*modifiers*/ undefined, setOriginalNode(createVariableDeclarationList([ + createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, createElementAccess(rhsReference, counter)) + ], /*location*/ ts.moveRangePos(initializer, -1)), initializer), + /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + // This is a destructuring pattern, so we flatten the destructuring instead. + statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, + /*needsValue*/ false, context.hoistVariableDeclaration, visitor, convertObjectRest))); + } + else { + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + assignment.end = initializer.end; + statements.push(createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the expression + setEmitFlags(expression, 1536 /* NoSourceMap */ | getEmitFlags(expression)); + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + var body = createBlock(createNodeArray(statements, /*location*/ statementsLocation), + /*location*/ bodyLocation); + setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); + var forStatement; + if (convertObjectRest) { + forStatement = createForOf(createVariableDeclarationList([ + createVariableDeclaration(rhsReference, /*type*/ undefined, /*initializer*/ undefined, /*location*/ node.expression) + ], /*location*/ node.expression), node.expression, body, + /*location*/ node); + } + else { + forStatement = createFor(setEmitFlags(createVariableDeclarationList([ + createVariableDeclaration(counter, /*type*/ undefined, createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), + createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) + ], /*location*/ node.expression), 16777216 /* NoHoisting */), createLessThan(counter, createPropertyAccess(rhsReference, "length"), + /*location*/ node.expression), createPostfixIncrement(counter, /*location*/ node.expression), body, + /*location*/ node); + } + // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. + setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); + return forStatement; + } + ts.convertForOf = convertForOf; })(ts || (ts = {})); /// /// @@ -12952,13 +13800,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 256 /* SourceFile */) { + if (kind === 260 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 70 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 140 /* FirstNode */) { + else if (kind < 141 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13001,26 +13849,28 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: + case 258 /* SpreadAssignment */: + return visitNode(cbNode, node.expression); + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13029,24 +13879,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13057,309 +13907,313 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 162 /* TupleType */: + case 163 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: + case 168 /* TypeOperator */: return visitNode(cbNode, node.type); - case 167 /* LiteralType */: + case 169 /* IndexedAccessType */: + return visitNode(cbNode, node.objectType) || + visitNode(cbNode, node.indexType); + case 170 /* LiteralType */: return visitNode(cbNode, node.literal); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 196 /* AsExpression */: + case 199 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: return visitNode(cbNode, node.label); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 249 /* CaseClause */: + case 252 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 144 /* Decorator */: + case 145 /* Decorator */: return visitNode(cbNode, node.expression); - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 241 /* ExternalModuleReference */: + case 244 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNodes, node.attributes); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitNode(cbNode, node.expression); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 257 /* JSDocTypeExpression */: + case 261 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 261 /* JSDocUnionType */: + case 265 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 262 /* JSDocTupleType */: + case 266 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 260 /* JSDocArrayType */: + case 264 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 264 /* JSDocNonNullableType */: + case 268 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 263 /* JSDocNullableType */: + case 267 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 265 /* JSDocRecordType */: + case 269 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 267 /* JSDocTypeReference */: + case 271 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 268 /* JSDocOptionalType */: + case 272 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 269 /* JSDocFunctionType */: + case 273 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 270 /* JSDocVariadicType */: + case 274 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 271 /* JSDocConstructorType */: + case 275 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 272 /* JSDocThisType */: + case 276 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 266 /* JSDocRecordMember */: + case 270 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 273 /* JSDocComment */: + case 277 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 275 /* JSDocParameterTag */: + case 279 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 276 /* JSDocReturnTag */: + case 280 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 277 /* JSDocTypeTag */: + case 281 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 278 /* JSDocTemplateTag */: + case 282 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 281 /* JSDocTypeLiteral */: + case 285 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 280 /* JSDocPropertyTag */: + case 284 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 282 /* JSDocLiteralType */: + case 286 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -13373,6 +14227,10 @@ var ts; return result; } ts.createSourceFile = createSourceFile; + function parseIsolatedEntityName(text, languageVersion) { + return Parser.parseIsolatedEntityName(text, languageVersion); + } + ts.parseIsolatedEntityName = parseIsolatedEntityName; function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -13414,8 +14272,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 32768 /* DisallowInContext */ | 131072 /* DecoratorContext */; + var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 65536 /* DisallowInContext */ | 262144 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var TokenConstructor; @@ -13513,6 +14371,16 @@ var ts; return result; } Parser.parseSourceFile = parseSourceFile; + function parseIsolatedEntityName(content, languageVersion) { + initializeState(content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + // Prime the scanner. + nextToken(); + var entityName = parseEntityName(/*allowReservedWords*/ true); + var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + clearState(); + return isInvalid ? entityName : undefined; + } + Parser.parseIsolatedEntityName = parseIsolatedEntityName; function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ ? 1 /* JSX */ : 0 /* Standard */; @@ -13529,7 +14397,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 1048576 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 2097152 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -13617,7 +14485,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(256 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(260 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -13637,16 +14505,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 32768 /* DisallowInContext */); + setContextFlag(val, 65536 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 65536 /* YieldContext */); + setContextFlag(val, 131072 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 131072 /* DecoratorContext */); + setContextFlag(val, 262144 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 262144 /* AwaitContext */); + setContextFlag(val, 524288 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -13687,40 +14555,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(32768 /* DisallowInContext */, func); + return doOutsideOfContext(65536 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(32768 /* DisallowInContext */, func); + return doInsideOfContext(65536 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(65536 /* YieldContext */, func); + return doInsideOfContext(131072 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(131072 /* DecoratorContext */, func); + return doInsideOfContext(262144 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(262144 /* AwaitContext */, func); + return doInsideOfContext(524288 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(262144 /* AwaitContext */, func); + return doOutsideOfContext(524288 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(65536 /* YieldContext */ | 262144 /* AwaitContext */, func); + return doInsideOfContext(131072 /* YieldContext */ | 524288 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(65536 /* YieldContext */); + return inContext(131072 /* YieldContext */); } function inDisallowInContext() { - return inContext(32768 /* DisallowInContext */); + return inContext(65536 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(131072 /* DecoratorContext */); + return inContext(262144 /* DecoratorContext */); } function inAwaitContext() { - return inContext(262144 /* AwaitContext */); + return inContext(524288 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -13901,7 +14769,7 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 140 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + return kind >= 141 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } @@ -13924,7 +14792,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 524288 /* ThisNodeHasError */; + node.flags |= 1048576 /* ThisNodeHasError */; } return node; } @@ -13993,7 +14861,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(141 /* ComputedPropertyName */); + var node = createNode(142 /* ComputedPropertyName */); parseExpected(20 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -14080,9 +14948,11 @@ var ts; // which would be a candidate for improved error reporting. return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + case 17 /* RestProperties */: + return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 20 /* OpenBracketToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: // If we see { } then only consume it as an expression if it is followed by , or { // That way we won't consume the body of a class in its heritage clause. @@ -14102,29 +14972,29 @@ var ts; return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); - case 18 /* TypeArguments */: - case 19 /* TupleElementTypes */: + case 19 /* TypeArguments */: + case 20 /* TupleElementTypes */: return token() === 25 /* CommaToken */ || isStartOfType(); - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: return isHeritageClause(); - case 21 /* ImportOrExportSpecifiers */: + case 22 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; - case 22 /* JSDocFunctionParameters */: - case 23 /* JSDocTypeArguments */: - case 25 /* JSDocTupleTypes */: + case 23 /* JSDocFunctionParameters */: + case 24 /* JSDocTypeArguments */: + case 26 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 24 /* JSDocRecordMembers */: + case 25 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -14177,7 +15047,7 @@ var ts; case 6 /* EnumMembers */: case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: - case 21 /* ImportOrExportSpecifiers */: + case 22 /* ImportOrExportSpecifiers */: return token() === 17 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; @@ -14185,35 +15055,36 @@ var ts; return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: // Tokens other than '>' are here for better error recovery return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: - case 19 /* TupleElementTypes */: + case 20 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: return token() === 21 /* CloseBracketToken */; case 16 /* Parameters */: + case 17 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 18 /* TypeArguments */: + case 19 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token return token() !== 25 /* CommaToken */; - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; case 13 /* JsxAttributes */: return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; case 14 /* JsxChildren */: return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); - case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocFunctionParameters */: return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; - case 23 /* JSDocTypeArguments */: + case 24 /* JSDocTypeArguments */: return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; - case 25 /* JSDocTupleTypes */: + case 26 /* JSDocTupleTypes */: return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; - case 24 /* JSDocRecordMembers */: + case 25 /* JSDocRecordMembers */: return token() === 17 /* CloseBraceToken */; } } @@ -14240,7 +15111,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 26 /* Count */; kind++) { + for (var kind = 0; kind < 27 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -14315,7 +15186,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 1540096 /* ContextFlags */; + var nodeContextFlags = node.flags & 3080192 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -14350,20 +15221,22 @@ var ts; return isReusableVariableDeclaration(node); case 16 /* Parameters */: return isReusableParameter(node); + case 17 /* RestProperties */: + return false; // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 20 /* HeritageClauses */: + case 21 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 17 /* TypeParameters */: + case 18 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 19 /* TupleElementTypes */: + case 20 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -14371,7 +15244,7 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 18 /* TypeArguments */: + case 19 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. @@ -14395,14 +15268,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 149 /* Constructor */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 146 /* PropertyDeclaration */: - case 199 /* SemicolonClassElement */: + case 150 /* Constructor */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 202 /* SemicolonClassElement */: return true; - case 148 /* MethodDeclaration */: + case 149 /* 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. @@ -14417,8 +15290,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: return true; } } @@ -14427,58 +15300,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 201 /* VariableStatement */: - case 200 /* Block */: - case 204 /* IfStatement */: - case 203 /* ExpressionStatement */: - case 216 /* ThrowStatement */: - case 212 /* ReturnStatement */: - case 214 /* SwitchStatement */: - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 207 /* ForStatement */: - case 206 /* WhileStatement */: - case 213 /* WithStatement */: - case 202 /* EmptyStatement */: - case 217 /* TryStatement */: - case 215 /* LabeledStatement */: - case 205 /* DoStatement */: - case 218 /* DebuggerStatement */: - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: - case 236 /* ExportAssignment */: - case 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 224 /* FunctionDeclaration */: + case 204 /* VariableStatement */: + case 203 /* Block */: + case 207 /* IfStatement */: + case 206 /* ExpressionStatement */: + case 219 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 217 /* SwitchStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 210 /* ForStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: + case 205 /* EmptyStatement */: + case 220 /* TryStatement */: + case 218 /* LabeledStatement */: + case 208 /* DoStatement */: + case 221 /* DebuggerStatement */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 227 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 255 /* EnumMember */; + return node.kind === 259 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 153 /* ConstructSignature */: - case 147 /* MethodSignature */: - case 154 /* IndexSignature */: - case 145 /* PropertySignature */: - case 152 /* CallSignature */: + case 154 /* ConstructSignature */: + case 148 /* MethodSignature */: + case 155 /* IndexSignature */: + case 146 /* PropertySignature */: + case 153 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 219 /* VariableDeclaration */) { + if (node.kind !== 222 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -14499,7 +15372,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 143 /* Parameter */) { + if (node.kind !== 144 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -14521,6 +15394,7 @@ var ts; 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 17 /* 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; @@ -14532,17 +15406,17 @@ var ts; case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 17 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 18 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 19 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 20 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 21 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 18 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 19 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 20 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 21 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; - case 22 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 23 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 25 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 24 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 23 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 24 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 26 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 25 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -14611,7 +15485,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(22 /* DotToken */)) { - var node = createNode(140 /* QualifiedName */, entity.pos); // !!! + var node = createNode(141 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14650,7 +15524,7 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(190 /* TemplateExpression */); + var template = createNode(193 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); @@ -14662,7 +15536,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(198 /* TemplateSpan */); + var span = createNode(201 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 17 /* CloseBraceToken */) { @@ -14717,33 +15591,33 @@ var ts; // TYPES function parseTypeReference() { var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(156 /* TypeReference */, typeName.pos); + var node = createNode(157 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(155 /* TypePredicate */, lhs.pos); + var node = createNode(156 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(166 /* ThisType */); + var node = createNode(167 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(159 /* TypeQuery */); + var node = createNode(160 /* TypeQuery */); parseExpected(102 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(142 /* TypeParameter */); + var node = createNode(143 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(84 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -14768,7 +15642,7 @@ var ts; } function parseTypeParameters() { if (token() === 26 /* LessThanToken */) { - return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } } function parseParameterType() { @@ -14781,7 +15655,7 @@ var ts; return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; } function parseParameter() { - var node = createNode(143 /* Parameter */); + var node = createNode(144 /* Parameter */); if (token() === 98 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true, undefined); node.type = parseParameterType(); @@ -14880,7 +15754,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 153 /* ConstructSignature */) { + if (kind === 154 /* ConstructSignature */) { parseExpected(93 /* NewKeyword */); } fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -14944,7 +15818,7 @@ var ts; return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(154 /* IndexSignature */, fullStart); + var node = createNode(155 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); @@ -14956,7 +15830,7 @@ var ts; var name = parsePropertyName(); var questionToken = parseOptionalToken(54 /* QuestionToken */); if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(147 /* MethodSignature */, fullStart); + var method = createNode(148 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; @@ -14967,7 +15841,7 @@ var ts; return addJSDocComment(finishNode(method)); } else { - var property = createNode(145 /* PropertySignature */, fullStart); + var property = createNode(146 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; @@ -15016,10 +15890,10 @@ var ts; } function parseTypeMember() { if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(152 /* CallSignature */); + return parseSignatureMember(153 /* CallSignature */); } if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(153 /* ConstructSignature */); + return parseSignatureMember(154 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -15033,7 +15907,7 @@ var ts; return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(160 /* TypeLiteral */); + var node = createNode(161 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15049,12 +15923,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(162 /* TupleType */); - node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + var node = createNode(163 /* TupleType */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(165 /* ParenthesizedType */); + var node = createNode(166 /* ParenthesizedType */); parseExpected(18 /* OpenParenToken */); node.type = parseType(); parseExpected(19 /* CloseParenToken */); @@ -15062,7 +15936,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 158 /* ConstructorType */) { + if (kind === 159 /* ConstructorType */) { parseExpected(93 /* NewKeyword */); } fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); @@ -15073,7 +15947,7 @@ var ts; return token() === 22 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(167 /* LiteralType */); + var node = createNode(170 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15084,12 +15958,12 @@ var ts; function parseNonArrayType() { switch (token()) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 135 /* SymbolKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); @@ -15127,16 +16001,16 @@ var ts; function isStartOfType() { switch (token()) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: case 98 /* ThisKeyword */: case 102 /* TypeOfKeyword */: - case 128 /* NeverKeyword */: + case 129 /* NeverKeyword */: case 16 /* OpenBraceToken */: case 20 /* OpenBracketToken */: case 26 /* LessThanToken */: @@ -15163,13 +16037,36 @@ var ts; function parseArrayTypeOrHigher() { var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { - parseExpected(21 /* CloseBracketToken */); - var node = createNode(161 /* ArrayType */, type.pos); - node.elementType = type; - type = finishNode(node); + if (isStartOfType()) { + var node = createNode(169 /* IndexedAccessType */, type.pos); + node.objectType = type; + node.indexType = parseType(); + parseExpected(21 /* CloseBracketToken */); + type = finishNode(node); + } + else { + var node = createNode(162 /* ArrayType */, type.pos); + node.elementType = type; + parseExpected(21 /* CloseBracketToken */); + type = finishNode(node); + } } return type; } + function parseTypeOperator(operator) { + var node = createNode(168 /* TypeOperator */); + parseExpected(operator); + node.operator = operator; + node.type = parseTypeOperatorOrHigher(); + return finishNode(node); + } + function parseTypeOperatorOrHigher() { + switch (token()) { + case 126 /* KeyOfKeyword */: + return parseTypeOperator(126 /* KeyOfKeyword */); + } + return parseArrayTypeOrHigher(); + } function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { var type = parseConstituentType(); if (token() === operator) { @@ -15185,10 +16082,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(164 /* IntersectionType */, parseArrayTypeOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(165 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(163 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(164 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); } function isStartOfFunctionType() { if (token() === 26 /* LessThanToken */) { @@ -15245,7 +16142,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(155 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(156 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15264,14 +16161,14 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(327680 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(655360 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(157 /* FunctionType */); + return parseFunctionOrConstructorType(158 /* FunctionType */); } if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(158 /* ConstructorType */); + return parseFunctionOrConstructorType(159 /* ConstructorType */); } return parseUnionTypeOrHigher(); } @@ -15472,7 +16369,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(191 /* YieldExpression */); + var node = createNode(194 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -15494,13 +16391,13 @@ var ts; ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(181 /* ArrowFunction */, asyncModifier.pos); + node = createNode(184 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(181 /* ArrowFunction */, identifier.pos); + node = createNode(184 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(143 /* Parameter */, identifier.pos); + var parameter = createNode(144 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); @@ -15682,7 +16579,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(181 /* ArrowFunction */); + var node = createNode(184 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -15748,7 +16645,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(189 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(192 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15761,7 +16658,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 139 /* OfKeyword */; + return t === 91 /* InKeyword */ || t === 140 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15869,39 +16766,39 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(188 /* BinaryExpression */, left.pos); + var node = createNode(191 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(196 /* AsExpression */, left.pos); + var node = createNode(199 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(189 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(182 /* DeleteExpression */); + var node = createNode(185 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(183 /* TypeOfExpression */); + var node = createNode(186 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(184 /* VoidExpression */); + var node = createNode(187 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15917,7 +16814,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(185 /* AwaitExpression */); + var node = createNode(188 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15960,7 +16857,7 @@ var ts; var simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === 39 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 178 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 181 /* TypeAssertionExpression */) { parseErrorAtPosition(start, simpleUnaryExpression.end - start, 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 { @@ -16056,7 +16953,7 @@ var ts; */ function parseIncrementExpression() { if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(186 /* PrefixUnaryExpression */); + var node = createNode(189 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -16069,7 +16966,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(187 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(190 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16173,7 +17070,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(173 /* PropertyAccessExpression */, expression.pos); + var node = createNode(176 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -16198,8 +17095,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 244 /* JsxOpeningElement */) { - var node = createNode(242 /* JsxElement */, opening.pos); + if (opening.kind === 247 /* JsxOpeningElement */) { + var node = createNode(245 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16209,7 +17106,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 243 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 246 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -16224,7 +17121,7 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(188 /* BinaryExpression */, result.pos); + var badNode = createNode(191 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16283,7 +17180,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(244 /* JsxOpeningElement */, fullStart); + node = createNode(247 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -16295,7 +17192,7 @@ var ts; parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(243 /* JsxSelfClosingElement */, fullStart); + node = createNode(246 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -16311,7 +17208,7 @@ var ts; var expression = token() === 98 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(176 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16319,7 +17216,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(248 /* JsxExpression */); + var node = createNode(251 /* JsxExpression */); parseExpected(16 /* OpenBraceToken */); if (token() !== 17 /* CloseBraceToken */) { node.expression = parseAssignmentExpressionOrHigher(); @@ -16338,7 +17235,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(246 /* JsxAttribute */); + var node = createNode(249 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 57 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -16353,7 +17250,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(247 /* JsxSpreadAttribute */); + var node = createNode(250 /* JsxSpreadAttribute */); parseExpected(16 /* OpenBraceToken */); parseExpected(23 /* DotDotDotToken */); node.expression = parseExpression(); @@ -16361,7 +17258,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(245 /* JsxClosingElement */); + var node = createNode(248 /* JsxClosingElement */); parseExpected(27 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16374,7 +17271,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(178 /* TypeAssertionExpression */); + var node = createNode(181 /* TypeAssertionExpression */); parseExpected(26 /* LessThanToken */); node.type = parseType(); parseExpected(28 /* GreaterThanToken */); @@ -16385,7 +17282,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(22 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(173 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(176 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -16393,14 +17290,14 @@ var ts; } if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(197 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(200 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(174 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(177 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -16416,7 +17313,7 @@ var ts; continue; } if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(177 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(180 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -16439,7 +17336,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(178 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16447,7 +17344,7 @@ var ts; continue; } else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(175 /* CallExpression */, expression.pos); + var callExpr = createNode(178 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16466,7 +17363,7 @@ var ts; if (!parseOptional(26 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + var typeArguments = parseDelimitedList(19 /* TypeArguments */, parseType); if (!parseExpected(28 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; @@ -16557,28 +17454,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(179 /* ParenthesizedExpression */); + var node = createNode(182 /* ParenthesizedExpression */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(192 /* SpreadElementExpression */); + var node = createNode(195 /* SpreadElement */); parseExpected(23 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(194 /* OmittedExpression */) : + token() === 25 /* CommaToken */ ? createNode(197 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(171 /* ArrayLiteralExpression */); + var node = createNode(174 /* ArrayLiteralExpression */); parseExpected(20 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16589,15 +17486,21 @@ var ts; } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(150 /* GetAccessor */, fullStart, decorators, modifiers); + return parseAccessorDeclaration(151 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(132 /* SetKeyword */)) { - return parseAccessorDeclaration(151 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(133 /* SetKeyword */)) { + return parseAccessorDeclaration(152 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); + var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + if (dotDotDotToken) { + var spreadElement = createNode(258 /* SpreadAssignment */, fullStart); + spreadElement.expression = parseAssignmentExpressionOrHigher(); + return addJSDocComment(finishNode(spreadElement)); + } var decorators = parseDecorators(); var modifiers = parseModifiers(); var accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers); @@ -16619,7 +17522,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(254 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(257 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; var equalsToken = parseOptionalToken(57 /* EqualsToken */); @@ -16630,7 +17533,7 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(253 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(256 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; @@ -16640,7 +17543,7 @@ var ts; } } function parseObjectLiteralExpression() { - var node = createNode(172 /* ObjectLiteralExpression */); + var node = createNode(175 /* ObjectLiteralExpression */); parseExpected(16 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16659,7 +17562,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(180 /* FunctionExpression */); + var node = createNode(183 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(88 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); @@ -16681,7 +17584,7 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(176 /* NewExpression */); + var node = createNode(179 /* NewExpression */); parseExpected(93 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); @@ -16692,7 +17595,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(200 /* Block */); + var node = createNode(203 /* Block */); if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16725,12 +17628,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(202 /* EmptyStatement */); + var node = createNode(205 /* EmptyStatement */); parseExpected(24 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(204 /* IfStatement */); + var node = createNode(207 /* IfStatement */); parseExpected(89 /* IfKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16740,7 +17643,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(205 /* DoStatement */); + var node = createNode(208 /* DoStatement */); parseExpected(80 /* DoKeyword */); node.statement = parseStatement(); parseExpected(105 /* WhileKeyword */); @@ -16755,7 +17658,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(206 /* WhileStatement */); + var node = createNode(209 /* WhileStatement */); parseExpected(105 /* WhileKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16778,21 +17681,21 @@ var ts; } var forOrForInOrForOfStatement; if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(208 /* ForInStatement */, pos); + var forInStatement = createNode(211 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(139 /* OfKeyword */)) { - var forOfStatement = createNode(209 /* ForOfStatement */, pos); + else if (parseOptional(140 /* OfKeyword */)) { + var forOfStatement = createNode(212 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(19 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(207 /* ForStatement */, pos); + var forStatement = createNode(210 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(24 /* SemicolonToken */); if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { @@ -16810,7 +17713,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 211 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 214 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16818,7 +17721,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(212 /* ReturnStatement */); + var node = createNode(215 /* ReturnStatement */); parseExpected(95 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16827,7 +17730,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(213 /* WithStatement */); + var node = createNode(216 /* WithStatement */); parseExpected(106 /* WithKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -16836,7 +17739,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(249 /* CaseClause */); + var node = createNode(252 /* CaseClause */); parseExpected(72 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(55 /* ColonToken */); @@ -16844,7 +17747,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(250 /* DefaultClause */); + var node = createNode(253 /* DefaultClause */); parseExpected(78 /* DefaultKeyword */); parseExpected(55 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -16854,12 +17757,12 @@ var ts; return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(214 /* SwitchStatement */); + var node = createNode(217 /* SwitchStatement */); parseExpected(97 /* SwitchKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(228 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(231 /* CaseBlock */, scanner.getStartPos()); parseExpected(16 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(17 /* CloseBraceToken */); @@ -16874,7 +17777,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(216 /* ThrowStatement */); + var node = createNode(219 /* ThrowStatement */); parseExpected(99 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -16882,7 +17785,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(217 /* TryStatement */); + var node = createNode(220 /* TryStatement */); parseExpected(101 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -16895,7 +17798,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(252 /* CatchClause */); + var result = createNode(255 /* CatchClause */); parseExpected(73 /* CatchKeyword */); if (parseExpected(18 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16905,7 +17808,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(218 /* DebuggerStatement */); + var node = createNode(221 /* DebuggerStatement */); parseExpected(77 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -16917,13 +17820,13 @@ var ts; var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(215 /* LabeledStatement */, fullStart); + var labeledStatement = createNode(218 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(203 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(206 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16973,10 +17876,10 @@ var ts; // // could be legal, it would add complexity for very little gain. case 108 /* InterfaceKeyword */: - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 116 /* AbstractKeyword */: case 119 /* AsyncKeyword */: @@ -16984,14 +17887,14 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 113 /* PublicKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 138 /* GlobalKeyword */: + case 139 /* GlobalKeyword */: nextToken(); return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; case 90 /* ImportKeyword */: @@ -17051,17 +17954,17 @@ var ts; case 119 /* AsyncKeyword */: case 123 /* DeclareKeyword */: case 108 /* InterfaceKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: - case 135 /* TypeKeyword */: - case 138 /* GlobalKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: + case 136 /* TypeKeyword */: + case 139 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* 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); @@ -17104,9 +18007,9 @@ var ts; case 87 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(210 /* ContinueStatement */); + return parseBreakOrContinueStatement(213 /* ContinueStatement */); case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(211 /* BreakStatement */); + return parseBreakOrContinueStatement(214 /* BreakStatement */); case 95 /* ReturnKeyword */: return parseReturnStatement(); case 106 /* WithKeyword */: @@ -17126,9 +18029,9 @@ var ts; return parseDeclaration(); case 119 /* AsyncKeyword */: case 108 /* InterfaceKeyword */: - case 135 /* TypeKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 136 /* TypeKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: case 82 /* EnumKeyword */: @@ -17139,8 +18042,8 @@ var ts; case 113 /* PublicKeyword */: case 116 /* AbstractKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: - case 138 /* GlobalKeyword */: + case 130 /* ReadonlyKeyword */: + case 139 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17163,13 +18066,13 @@ var ts; return parseClassDeclaration(fullStart, decorators, modifiers); case 108 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); case 82 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 138 /* GlobalKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: + case 139 /* GlobalKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); case 90 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); @@ -17188,7 +18091,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 node = createMissingNode(240 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(243 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17210,16 +18113,17 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 25 /* CommaToken */) { - return createNode(194 /* OmittedExpression */); + return createNode(197 /* OmittedExpression */); } - var node = createNode(170 /* BindingElement */); + var node = createNode(173 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(170 /* BindingElement */); + var node = createNode(173 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { @@ -17234,14 +18138,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(168 /* ObjectBindingPattern */); + var node = createNode(171 /* ObjectBindingPattern */); parseExpected(16 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(17 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(169 /* ArrayBindingPattern */); + var node = createNode(172 /* ArrayBindingPattern */); parseExpected(20 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(21 /* CloseBracketToken */); @@ -17260,7 +18164,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(219 /* VariableDeclaration */); + var node = createNode(222 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17269,7 +18173,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(220 /* VariableDeclarationList */); + var node = createNode(223 /* VariableDeclarationList */); switch (token()) { case 103 /* VarKeyword */: break; @@ -17292,7 +18196,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 139 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 140 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17307,7 +18211,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(201 /* VariableStatement */, fullStart); + var node = createNode(204 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -17315,7 +18219,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(221 /* FunctionDeclaration */, fullStart); + var node = createNode(224 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(88 /* FunctionKeyword */); @@ -17328,7 +18232,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(149 /* Constructor */, pos); + var node = createNode(150 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; parseExpected(122 /* ConstructorKeyword */); @@ -17337,7 +18241,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(148 /* MethodDeclaration */, fullStart); + var method = createNode(149 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -17350,7 +18254,7 @@ var ts; return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(146 /* PropertyDeclaration */, fullStart); + var property = createNode(147 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -17367,7 +18271,7 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = ts.hasModifier(property, 32 /* Static */) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(65536 /* YieldContext */ | 32768 /* DisallowInContext */, parseNonParameterInitializer); + : doOutsideOfContext(131072 /* YieldContext */ | 65536 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -17402,7 +18306,7 @@ var ts; case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: case 114 /* StaticKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: return true; default: return false; @@ -17443,7 +18347,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 === 132 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 133 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -17473,7 +18377,7 @@ var ts; if (!parseOptional(56 /* AtToken */)) { break; } - var decorator = createNode(144 /* Decorator */, decoratorStart); + var decorator = createNode(145 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17539,7 +18443,7 @@ var ts; } function parseClassElement() { if (token() === 24 /* SemicolonToken */) { - var result = createNode(199 /* SemicolonClassElement */); + var result = createNode(202 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -17567,8 +18471,8 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_10 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_10, /*questionToken*/ undefined); + var name_14 = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_14, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -17577,10 +18481,10 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 193 /* ClassExpression */); + /*modifiers*/ undefined, 196 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 222 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 225 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); @@ -17618,13 +18522,13 @@ var ts; // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(20 /* HeritageClauses */, parseHeritageClause); + return parseList(21 /* HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(251 /* HeritageClause */); + var node = createNode(254 /* HeritageClause */); node.token = token(); nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -17633,10 +18537,10 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(195 /* ExpressionWithTypeArguments */); + var node = createNode(198 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); } return finishNode(node); } @@ -17647,7 +18551,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(223 /* InterfaceDeclaration */, fullStart); + var node = createNode(226 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(108 /* InterfaceKeyword */); @@ -17658,10 +18562,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(224 /* TypeAliasDeclaration */, fullStart); + var node = createNode(227 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(135 /* TypeKeyword */); + parseExpected(136 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); parseExpected(57 /* EqualsToken */); @@ -17674,13 +18578,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(255 /* EnumMember */, scanner.getStartPos()); + var node = createNode(259 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(225 /* EnumDeclaration */, fullStart); + var node = createNode(228 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; parseExpected(82 /* EnumKeyword */); @@ -17695,7 +18599,7 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(227 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(230 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(16 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(17 /* CloseBraceToken */); @@ -17706,7 +18610,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(229 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -17720,10 +18624,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(226 /* ModuleDeclaration */, fullStart); + var node = createNode(229 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 138 /* GlobalKeyword */) { + if (token() === 139 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -17741,15 +18645,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 138 /* GlobalKeyword */) { + if (token() === 139 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(127 /* NamespaceKeyword */)) { + else if (parseOptional(128 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(126 /* ModuleKeyword */); + parseExpected(127 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17757,7 +18661,7 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 130 /* RequireKeyword */ && + return token() === 131 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -17767,11 +18671,11 @@ var ts; return nextToken() === 40 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(229 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(232 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; parseExpected(117 /* AsKeyword */); - parseExpected(127 /* NamespaceKeyword */); + parseExpected(128 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); @@ -17782,11 +18686,11 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 137 /* FromKeyword */) { + if (token() !== 25 /* CommaToken */ && token() !== 138 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(230 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(233 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; importEqualsDeclaration.name = identifier; @@ -17797,7 +18701,7 @@ var ts; } } // Import statement - var importDeclaration = createNode(231 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(234 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: @@ -17807,7 +18711,7 @@ var ts; token() === 38 /* AsteriskToken */ || token() === 16 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); @@ -17820,7 +18724,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(232 /* ImportClause */, fullStart); + var importClause = createNode(235 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -17830,7 +18734,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(234 /* NamedImports */); + importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(237 /* NamedImports */); } return finishNode(importClause); } @@ -17840,8 +18744,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(241 /* ExternalModuleReference */); - parseExpected(130 /* RequireKeyword */); + var node = createNode(244 /* ExternalModuleReference */); + parseExpected(131 /* RequireKeyword */); parseExpected(18 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(19 /* CloseParenToken */); @@ -17863,7 +18767,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(233 /* NamespaceImport */); + var namespaceImport = createNode(236 /* NamespaceImport */); parseExpected(38 /* AsteriskToken */); parseExpected(117 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -17878,14 +18782,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 234 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 237 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(239 /* ExportSpecifier */); + return parseImportOrExportSpecifier(242 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(235 /* ImportSpecifier */); + return parseImportOrExportSpecifier(238 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17910,27 +18814,27 @@ var ts; else { node.name = identifierName; } - if (kind === 235 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 238 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(237 /* ExportDeclaration */, fullStart); + var node = createNode(240 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(137 /* FromKeyword */); + parseExpected(138 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(238 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(241 /* 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() === 137 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(137 /* FromKeyword */); + if (token() === 138 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(138 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17938,7 +18842,7 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(236 /* ExportAssignment */, fullStart); + var node = createNode(239 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; if (parseOptional(57 /* EqualsToken */)) { @@ -18020,10 +18924,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 230 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 241 /* ExternalModuleReference */ - || node.kind === 231 /* ImportDeclaration */ - || node.kind === 236 /* ExportAssignment */ - || node.kind === 237 /* ExportDeclaration */ + || node.kind === 233 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 244 /* ExternalModuleReference */ + || node.kind === 234 /* ImportDeclaration */ + || node.kind === 239 /* ExportAssignment */ + || node.kind === 240 /* ExportDeclaration */ ? node : undefined; }); @@ -18047,16 +18951,17 @@ var ts; ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 26] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["RestProperties"] = 17] = "RestProperties"; + ParsingContext[ParsingContext["TypeParameters"] = 18] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 19] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 20] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 21] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 22] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 23] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 24] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 25] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 26] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 27] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -18084,8 +18989,8 @@ var ts; } JSDocParser.isJSDocType = isJSDocType; function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = createSourceFile("file.js", 4 /* Latest */, 1 /* JS */); + initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + sourceFile = createSourceFile("file.js", 5 /* Latest */, 1 /* JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); @@ -18097,7 +19002,7 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(257 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(261 /* JSDocTypeExpression */, scanner.getTokenPos()); parseExpected(16 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(17 /* CloseBraceToken */); @@ -18108,12 +19013,12 @@ var ts; function parseJSDocTopLevelType() { var type = parseJSDocType(); if (token() === 48 /* BarToken */) { - var unionType = createNode(261 /* JSDocUnionType */, type.pos); + var unionType = createNode(265 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(268 /* JSDocOptionalType */, type.pos); + var optionalType = createNode(272 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -18124,20 +19029,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(260 /* JSDocArrayType */, type.pos); + var arrayType = createNode(264 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(21 /* CloseBracketToken */); type = finishNode(arrayType); } else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(263 /* JSDocNullableType */, type.pos); + var nullableType = createNode(267 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(264 /* JSDocNonNullableType */, type.pos); + var nonNullableType = createNode(268 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -18171,14 +19076,14 @@ var ts; case 98 /* ThisKeyword */: return parseJSDocThisType(); case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: case 94 /* NullKeyword */: - case 136 /* UndefinedKeyword */: - case 128 /* NeverKeyword */: + case 137 /* UndefinedKeyword */: + case 129 /* NeverKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -18189,30 +19094,30 @@ var ts; return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(272 /* JSDocThisType */); + var result = createNode(276 /* JSDocThisType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(271 /* JSDocConstructorType */); + var result = createNode(275 /* JSDocConstructorType */); nextToken(); parseExpected(55 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(270 /* JSDocVariadicType */); + var result = createNode(274 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(269 /* JSDocFunctionType */); + var result = createNode(273 /* JSDocFunctionType */); nextToken(); parseExpected(18 /* OpenParenToken */); - result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(19 /* CloseParenToken */); if (token() === 55 /* ColonToken */) { @@ -18222,7 +19127,7 @@ var ts; return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(143 /* Parameter */); + var parameter = createNode(144 /* Parameter */); parameter.type = parseJSDocType(); if (parseOptional(57 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? @@ -18231,7 +19136,7 @@ var ts; return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(267 /* JSDocTypeReference */); + var result = createNode(271 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); if (token() === 26 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); @@ -18252,7 +19157,7 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(24 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); parseExpected(28 /* GreaterThanToken */); @@ -18266,26 +19171,26 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(140 /* QualifiedName */, left.pos); + var result = createNode(141 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(265 /* JSDocRecordType */); + var result = createNode(269 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(264 /* JSDocNonNullableType */); + var result = createNode(268 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(262 /* JSDocTupleType */); + var result = createNode(266 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(21 /* CloseBracketToken */); return finishNode(result); @@ -18297,7 +19202,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(261 /* JSDocUnionType */); + var result = createNode(265 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(19 /* CloseParenToken */); @@ -18313,12 +19218,12 @@ var ts; return types; } function parseJSDocAllType() { - var result = createNode(258 /* JSDocAllType */); + var result = createNode(262 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(282 /* JSDocLiteralType */); + var result = createNode(286 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -18341,17 +19246,17 @@ var ts; token() === 28 /* GreaterThanToken */ || token() === 57 /* EqualsToken */ || token() === 48 /* BarToken */) { - var result = createNode(259 /* JSDocUnknownType */, pos); + var result = createNode(263 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(263 /* JSDocNullableType */, pos); + var result = createNode(267 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } } function parseIsolatedJSDocComment(content, start, length) { - initializeState(content, 4 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState(content, 5 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); sourceFile = { languageVariant: 0 /* Standard */, text: content }; var jsDoc = parseJSDocCommentWorker(start, length); var diagnostics = parseDiagnostics; @@ -18504,7 +19409,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(273 /* JSDocComment */, start); + var result = createNode(277 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18617,7 +19522,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(274 /* JSDocTag */, atToken.pos); + var result = createNode(278 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18674,7 +19579,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(275 /* JSDocParameterTag */, atToken.pos); + var result = createNode(279 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18685,20 +19590,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 276 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 280 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(276 /* JSDocReturnTag */, atToken.pos); + var result = createNode(280 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 277 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 281 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(277 /* JSDocTypeTag */, atToken.pos); + var result = createNode(281 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18713,7 +19618,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(280 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(284 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18723,7 +19628,7 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(279 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(283 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); @@ -18737,11 +19642,11 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 267 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 271 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70 /* Identifier */) { - var name_11 = jsDocTypeReference.name; - if (name_11.text === "Object") { + var name_15 = jsDocTypeReference.name; + if (name_15.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -18755,7 +19660,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(281 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(285 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18796,7 +19701,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(226 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(229 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -18842,20 +19747,20 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 278 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } // Type parameter list looks like '@template T,U,V' var typeParameters = createNodeArray(); while (true) { - var name_12 = parseJSDocIdentifierName(); + var name_16 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_12) { + if (!name_16) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(142 /* TypeParameter */, name_12.pos); - typeParameter.name = name_12; + var typeParameter = createNode(143 /* TypeParameter */, name_16.pos); + typeParameter.name = name_16; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25 /* CommaToken */) { @@ -18866,7 +19771,7 @@ var ts; break; } } - var result = createNode(278 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(282 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -19377,25 +20282,25 @@ var ts; /* @internal */ var ts; (function (ts) { + var ModuleInstanceState; (function (ModuleInstanceState) { ModuleInstanceState[ModuleInstanceState["NonInstantiated"] = 0] = "NonInstantiated"; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; - })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - var ModuleInstanceState = ts.ModuleInstanceState; + })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 226 /* InterfaceDeclaration */ || node.kind === 227 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 234 /* ImportDeclaration */ || node.kind === 233 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 227 /* ModuleBlock */) { + else if (node.kind === 230 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19414,7 +20319,7 @@ var ts; }); return state_1; } - else if (node.kind === 226 /* ModuleDeclaration */) { + else if (node.kind === 229 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } @@ -19555,7 +20460,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 226 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 229 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -19568,7 +20473,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -19580,21 +20485,21 @@ var ts; return node.name.text; } switch (node.kind) { - case 149 /* Constructor */: + case 150 /* Constructor */: return "__constructor"; - case 157 /* FunctionType */: - case 152 /* CallSignature */: + case 158 /* FunctionType */: + case 153 /* CallSignature */: return "__call"; - case 158 /* ConstructorType */: - case 153 /* ConstructSignature */: + case 159 /* ConstructorType */: + case 154 /* ConstructSignature */: return "__new"; - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return "__index"; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return "__export"; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... @@ -19609,22 +20514,22 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: + case 224 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 269 /* JSDocFunctionType */: + case 273 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 143 /* Parameter */: + case 144 /* 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 === 269 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 273 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 204 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -19711,7 +20616,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 && - (isDefaultExport || (node.kind === 236 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 239 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19731,7 +20636,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 239 /* ExportSpecifier */ || (node.kind === 230 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 242 /* ExportSpecifier */ || (node.kind === 233 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19754,7 +20659,7 @@ var ts; // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - var isJSDocTypedefInJSDocNamespace = node.kind === 279 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 283 /* JSDocTypedefTag */ && node.name && node.name.kind === 70 /* Identifier */ && node.name.isInJSDocNamespace; @@ -19816,8 +20721,8 @@ var ts; var saveReturnTarget = currentReturnTarget; var saveActiveLabels = activeLabels; var saveHasExplicitReturn = hasExplicitReturn; - var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !!ts.getImmediatelyInvokedFunctionExpression(node); - // An IIFE is considered part of the containing control flow. Return statements behave + var isIIFE = containerFlags & 16 /* IsFunctionExpression */ && !ts.hasModifier(node, 256 /* Async */) && !!ts.getImmediatelyInvokedFunctionExpression(node); + // A non-async IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (isIIFE) { currentReturnTarget = createBranchLabel(); @@ -19836,13 +20741,13 @@ var ts; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) // Reset all emit helper flags on node (for incremental scenarios) - node.flags &= ~32128 /* ReachabilityAndEmitFlags */; + node.flags &= ~64896 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { node.flags |= 128 /* HasImplicitReturn */; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -19898,64 +20803,64 @@ var ts; return; } switch (node.kind) { - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: bindWhileStatement(node); break; - case 205 /* DoStatement */: + case 208 /* DoStatement */: bindDoStatement(node); break; - case 207 /* ForStatement */: + case 210 /* ForStatement */: bindForStatement(node); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 204 /* IfStatement */: + case 207 /* IfStatement */: bindIfStatement(node); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 219 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 217 /* TryStatement */: + case 220 /* TryStatement */: bindTryStatement(node); break; - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: bindSwitchStatement(node); break; - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: bindCaseBlock(node); break; - case 249 /* CaseClause */: + case 252 /* CaseClause */: bindCaseClause(node); break; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: bindLabeledStatement(node); break; - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 175 /* CallExpression */: + case 178 /* CallExpression */: bindCallExpressionFlow(node); break; default: @@ -19967,15 +20872,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return hasNarrowableArgument(expr); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -19983,7 +20888,7 @@ var ts; function isNarrowableReference(expr) { return expr.kind === 70 /* Identifier */ || expr.kind === 98 /* ThisKeyword */ || - expr.kind === 173 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 176 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19994,14 +20899,14 @@ var ts; } } } - if (expr.expression.kind === 173 /* PropertyAccessExpression */ && + if (expr.expression.kind === 176 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 183 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 186 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { @@ -20022,9 +20927,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 57 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -20119,33 +21024,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 204 /* IfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 207 /* IfStatement */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: return parent.expression === node; - case 207 /* ForStatement */: - case 189 /* ConditionalExpression */: + case 210 /* ForStatement */: + case 192 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 182 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 186 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 189 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 188 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || + return node.kind === 191 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 53 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 179 /* ParenthesizedExpression */ || - node.parent.kind === 186 /* PrefixUnaryExpression */ && + while (node.parent.kind === 182 /* ParenthesizedExpression */ || + node.parent.kind === 189 /* PrefixUnaryExpression */ && node.parent.operator === 50 /* ExclamationToken */) { node = node.parent; } @@ -20187,8 +21092,13 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var preConditionLabel = createBranchLabel(); - var postDoLabel = createBranchLabel(); + var enclosingLabeledStatement = node.parent.kind === 218 /* LabeledStatement */ + ? ts.lastOrUndefined(activeLabels) + : undefined; + // if do statement is wrapped in labeled statement then target labels for break/continue with or without + // label should be the same + var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); + var postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel(); addAntecedent(preDoLabel, currentFlow); currentFlow = preDoLabel; bindIterativeStatement(node.statement, postDoLabel, preConditionLabel); @@ -20219,7 +21129,7 @@ var ts; bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 220 /* VariableDeclarationList */) { + if (node.initializer.kind !== 223 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20241,7 +21151,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 212 /* ReturnStatement */) { + if (node.kind === 215 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20261,7 +21171,7 @@ var ts; return undefined; } function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 211 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 214 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20327,7 +21237,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 250 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 253 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -20390,11 +21300,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - addAntecedent(postStatementLabel, currentFlow); - currentFlow = finishFlowLabel(postStatementLabel); + if (!node.statement || node.statement.kind !== 208 /* DoStatement */) { + // do statement sets current flow inside bindDoStatement + addAntecedent(postStatementLabel, currentFlow); + currentFlow = finishFlowLabel(postStatementLabel); + } } function bindDestructuringTargetFlow(node) { - if (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -20405,10 +21318,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 171 /* ArrayLiteralExpression */) { + else if (node.kind === 174 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 192 /* SpreadElementExpression */) { + if (e.kind === 195 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -20416,15 +21329,18 @@ var ts; } } } - else if (node.kind === 172 /* ObjectLiteralExpression */) { + else if (node.kind === 175 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 253 /* PropertyAssignment */) { + if (p.kind === 256 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 254 /* ShorthandPropertyAssignment */) { + else if (p.kind === 257 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } + else if (p.kind === 258 /* SpreadAssignment */) { + bindAssignmentTargetFlow(p.expression); + } } } } @@ -20476,9 +21392,9 @@ var ts; } else { ts.forEachChild(node, bind); - if (operator === 57 /* EqualsToken */ && !ts.isAssignmentTarget(node)) { + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (node.left.kind === 174 /* ElementAccessExpression */) { + if (operator === 57 /* EqualsToken */ && node.left.kind === 177 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20489,7 +21405,7 @@ var ts; } function bindDeleteExpressionFlow(node) { ts.forEachChild(node, bind); - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 176 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -20499,9 +21415,11 @@ var ts; var postExpressionLabel = createBranchLabel(); bindCondition(node.condition, trueLabel, falseLabel); currentFlow = finishFlowLabel(trueLabel); + bind(node.questionToken); bind(node.whenTrue); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(falseLabel); + bind(node.colonToken); bind(node.whenFalse); addAntecedent(postExpressionLabel, currentFlow); currentFlow = finishFlowLabel(postExpressionLabel); @@ -20520,7 +21438,7 @@ var ts; } function bindVariableDeclarationFlow(node) { ts.forEachChild(node, bind); - if (node.initializer || node.parent.parent.kind === 208 /* ForInStatement */ || node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 211 /* ForInStatement */ || node.parent.parent.kind === 212 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } @@ -20529,10 +21447,10 @@ 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 = node.expression; - while (expr.kind === 179 /* ParenthesizedExpression */) { + while (expr.kind === 182 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 180 /* FunctionExpression */ || expr.kind === 181 /* ArrowFunction */) { + if (expr.kind === 183 /* FunctionExpression */ || expr.kind === 184 /* ArrowFunction */) { ts.forEach(node.typeArguments, bind); ts.forEach(node.arguments, bind); bind(node.expression); @@ -20540,7 +21458,7 @@ var ts; else { ts.forEachChild(node, bind); } - if (node.expression.kind === 173 /* PropertyAccessExpression */) { + if (node.expression.kind === 176 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20549,51 +21467,51 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 269 /* JSDocRecordType */: return 1 /* IsContainer */; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 269 /* JSDocFunctionType */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 273 /* JSDocFunctionType */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 256 /* SourceFile */: + case 260 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 149 /* Constructor */: - case 221 /* FunctionDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 150 /* Constructor */: + case 224 /* FunctionDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 252 /* CatchClause */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 228 /* CaseBlock */: + case 255 /* CatchClause */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 231 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 200 /* Block */: + case 203 /* 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 @@ -20630,41 +21548,41 @@ 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 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 160 /* TypeLiteral */: - case 172 /* ObjectLiteralExpression */: - case 223 /* InterfaceDeclaration */: - case 265 /* JSDocRecordType */: - case 281 /* JSDocTypeLiteral */: + case 161 /* TypeLiteral */: + case 175 /* ObjectLiteralExpression */: + case 226 /* InterfaceDeclaration */: + case 269 /* JSDocRecordType */: + case 285 /* JSDocTypeLiteral */: // 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 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 269 /* JSDocFunctionType */: - case 224 /* TypeAliasDeclaration */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 273 /* JSDocFunctionType */: + case 227 /* TypeAliasDeclaration */: // 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 @@ -20685,11 +21603,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 256 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 256 /* SourceFile */ || body.kind === 227 /* ModuleBlock */)) { + var body = node.kind === 260 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 260 /* SourceFile */ || body.kind === 230 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 237 /* ExportDeclaration */ || stat.kind === 236 /* ExportAssignment */) { + if (stat.kind === 240 /* ExportDeclaration */ || stat.kind === 239 /* ExportAssignment */) { return true; } } @@ -20782,7 +21700,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 258 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { continue; } var identifier = prop.name; @@ -20794,7 +21712,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 === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */ || prop.kind === 148 /* MethodDeclaration */ + var currentKind = prop.kind === 256 /* PropertyAssignment */ || prop.kind === 257 /* ShorthandPropertyAssignment */ || prop.kind === 149 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -20816,10 +21734,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -20930,8 +21848,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 256 /* SourceFile */ && - blockScopeContainer.kind !== 226 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 260 /* SourceFile */ && + blockScopeContainer.kind !== 229 /* 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. @@ -20997,7 +21915,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 > 139 /* LastToken */) { + if (node.kind > 140 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -21044,23 +21962,23 @@ var ts; // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 279 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 283 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 254 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 257 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (ts.isInJavaScriptFile(node)) { var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { @@ -21084,123 +22002,139 @@ var ts; } } return checkStrictModeBinaryExpression(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return checkStrictModeCatchClause(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return checkStrictModeWithStatement(node); - case 166 /* ThisType */: + case 167 /* ThisType */: seenThisKeyword = true; return; - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return checkTypePredicate(node); - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 143 /* Parameter */: + case 144 /* Parameter */: return bindParameter(node); - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + if (node.dotDotDotToken && node.parent.kind === 171 /* ObjectBindingPattern */) { + emitFlags |= 32768 /* HasRestAttribute */; + } return bindVariableDeclarationOrBindingElement(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 266 /* JSDocRecordMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 270 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 280 /* JSDocPropertyTag */: + case 284 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 247 /* JsxSpreadAttribute */: - emitFlags |= 16384 /* HasJsxSpreadAttributes */; + case 258 /* SpreadAssignment */: + case 250 /* JsxSpreadAttribute */: + var root = container; + var hasRest = false; + while (root.parent) { + if (root.kind === 175 /* ObjectLiteralExpression */ && + root.parent.kind === 191 /* BinaryExpression */ && + root.parent.operatorToken.kind === 57 /* EqualsToken */ && + root.parent.left === root) { + hasRest = true; + break; + } + root = root.parent; + } + emitFlags |= hasRest ? 32768 /* HasRestAttribute */ : 16384 /* HasSpreadAttribute */; return; - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* 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 ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 273 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 265 /* JSDocRecordType */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 269 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return bindFunctionExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Imports and exports - case 230 /* ImportEqualsDeclaration */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return bindImportClause(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return bindExportDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return bindExportAssignment(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 200 /* Block */: + case 203 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // Fall through - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } @@ -21209,7 +22143,7 @@ var ts; if (parameterName && parameterName.kind === 70 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 166 /* ThisType */) { + if (parameterName && parameterName.kind === 167 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -21232,7 +22166,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 236 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 239 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -21242,17 +22176,17 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 256 /* SourceFile */) { + if (node.parent.kind !== 260 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } else { - var parent_6 = node.parent; - if (!ts.isExternalModule(parent_6)) { + var parent_5 = node.parent; + if (!ts.isExternalModule(parent_5)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_6.isDeclarationFile) { + if (!parent_5.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -21297,12 +22231,12 @@ var ts; function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 221 /* FunctionDeclaration */ || container.kind === 180 /* FunctionExpression */) { + if (container.kind === 224 /* FunctionDeclaration */ || container.kind === 183 /* FunctionExpression */) { container.symbol.members = container.symbol.members || ts.createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } - else if (container.kind === 149 /* Constructor */) { + else if (container.kind === 150 /* Constructor */) { // this.foo assignment in a JavaScript class // Bind this property to the containing class var saveContainer = container; @@ -21353,7 +22287,7 @@ var ts; emitFlags |= 2048 /* HasDecorators */; } } - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -21497,13 +22431,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 202 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 205 /* EmptyStatement */) || // report error on class declarations - node.kind === 222 /* ClassDeclaration */ || + node.kind === 225 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 226 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 229 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 225 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 228 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -21517,7 +22451,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 201 /* VariableStatement */ || + (node.kind !== 204 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21537,56 +22471,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 143 /* Parameter */: + case 144 /* Parameter */: return computeParameter(node, subtreeFlags); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 149 /* Constructor */: + case 150 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21600,21 +22534,21 @@ var ts; if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */ + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */ || isSuperOrSuperProperty(expression, expressionKind)) { - // If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6 + // If the this node contains a SpreadExpression, or is a super call, then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~545281365 /* ArrayLiteralOrCallOrNewExcludes */; } function isSuperOrSuperProperty(node, kind) { switch (kind) { case 96 /* SuperKeyword */: return true; - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; return expressionKind === 96 /* SuperKeyword */; @@ -21626,31 +22560,34 @@ var ts; if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { // If the this node contains a SpreadElementExpression then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~537922901 /* ArrayLiteralOrCallOrNewExcludes */; + return transformFlags & ~545281365 /* ArrayLiteralOrCallOrNewExcludes */; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ - && (leftKind === 172 /* ObjectLiteralExpression */ - || leftKind === 171 /* ArrayLiteralExpression */)) { - // Destructuring assignments are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 1024 /* DestructuringAssignment */; + if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 175 /* ObjectLiteralExpression */) { + // Destructuring object assignments with are ES2015 syntax + // and possibly ESNext if they contain rest + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 49152 /* AssertDestructuringAssignment */; + } + else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 174 /* ArrayLiteralExpression */) { + // Destructuring assignments are ES2015 syntax. + transformFlags |= 3072 /* AssertES2015 */ | 49152 /* AssertDestructuringAssignment */; } else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. - transformFlags |= 192 /* AssertES2016 */; + transformFlags |= 768 /* AssertES2016 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21662,21 +22599,25 @@ var ts; // syntax. if (node.questionToken || node.type - || subtreeFlags & 8192 /* ContainsDecorators */ + || subtreeFlags & 65536 /* ContainsDecorators */ || ts.isThisIdentifier(name)) { transformFlags |= 3 /* AssertTypeScript */; } // If a parameter has an accessibility modifier, then it is TypeScript syntax. if (modifierFlags & 92 /* ParameterPropertyModifier */) { - transformFlags |= 3 /* AssertTypeScript */ | 524288 /* ContainsParameterPropertyAssignments */; + transformFlags |= 3 /* AssertTypeScript */ | 4194304 /* ContainsParameterPropertyAssignments */; + } + // parameters with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a parameter has an initializer, a binding pattern or a dotDotDot token, then // it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel. - if (subtreeFlags & 8388608 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { - transformFlags |= 768 /* AssertES2015 */ | 262144 /* ContainsDefaultValueAssignments */; + if (subtreeFlags & 67108864 /* ContainsBindingPattern */ || initializer || dotDotDotToken) { + transformFlags |= 3072 /* AssertES2015 */ | 2097152 /* ContainsDefaultValueAssignments */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~545262933 /* ParameterExcludes */; + return transformFlags & ~604001621 /* ParameterExcludes */; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21686,17 +22627,17 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 196 /* AsExpression */ - || expressionKind === 178 /* TypeAssertionExpression */) { + if (expressionKind === 199 /* AsExpression */ + || expressionKind === 181 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, // then the ParenthesizedExpression is a destructuring assignment. - if (expressionTransformFlags & 1024 /* DestructuringAssignment */) { - transformFlags |= 1024 /* DestructuringAssignment */; + if (expressionTransformFlags & 16384 /* DestructuringAssignment */) { + transformFlags |= 16384 /* DestructuringAssignment */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -21707,47 +22648,47 @@ var ts; } else { // A ClassDeclaration is ES6 syntax. - transformFlags = subtreeFlags | 768 /* AssertES2015 */; + transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - // An exported declaration may be TypeScript syntax. - if ((subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */) - || (modifierFlags & 1 /* Export */) + // An exported declaration may be TypeScript syntax, but is handled by the visitor + // for a namespace declaration. + if ((subtreeFlags & 4390912 /* TypeScriptClassSyntaxMask */) || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~539749717 /* ClassExcludes */; + return transformFlags & ~559895893 /* ClassExcludes */; } function computeClassExpression(node, subtreeFlags) { // A ClassExpression is ES6 syntax. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // A class with a parameter property assignment, property initializer, or decorator is // TypeScript syntax. - if (subtreeFlags & 548864 /* TypeScriptClassSyntaxMask */ + if (subtreeFlags & 4390912 /* TypeScriptClassSyntaxMask */ || node.typeParameters) { transformFlags |= 3 /* AssertTypeScript */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~539749717 /* ClassExcludes */; + return transformFlags & ~559895893 /* ClassExcludes */; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; case 107 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. @@ -21758,27 +22699,27 @@ var ts; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeExpressionWithTypeArguments(node, subtreeFlags) { // An ExpressionWithTypeArguments is ES6 syntax, as it is used in the // extends clause of a class. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // If an ExpressionWithTypeArguments contains type arguments, then it // is TypeScript syntax. if (node.typeArguments) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21788,11 +22729,11 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* ConstructorExcludes */; + return transformFlags & ~975983957 /* ConstructorExcludes */; } function computeMethod(node, subtreeFlags) { // A MethodDeclaration is ES6 syntax. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // Decorators, TypeScript-specific modifiers, type parameters, type annotations, and // overloads are TypeScript syntax. if (node.decorators @@ -21804,14 +22745,14 @@ var ts; } // An async method declaration is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; } // Currently, we only support generators that were originally async function bodies. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; + return transformFlags & ~975983957 /* MethodOrAccessorExcludes */; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21824,7 +22765,7 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~591760725 /* MethodOrAccessorExcludes */; + return transformFlags & ~975983957 /* MethodOrAccessorExcludes */; } function computePropertyDeclaration(node, subtreeFlags) { // A PropertyDeclaration is TypeScript syntax. @@ -21832,10 +22773,10 @@ var ts; // If the PropertyDeclaration has an initializer, we need to inform its ancestor // so that it handle the transformation. if (node.initializer) { - transformFlags |= 16384 /* ContainsPropertyInitializer */; + transformFlags |= 131072 /* ContainsPropertyInitializer */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -21847,11 +22788,7 @@ var ts; transformFlags = 3 /* AssertTypeScript */; } else { - transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; - // If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & 1 /* Export */) { - transformFlags |= 3 /* AssertTypeScript */ | 768 /* AssertES2015 */; - } + transformFlags = subtreeFlags | 268435456 /* ContainsHoistedDeclarationOrCompletion */; // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript // syntax. if (modifierFlags & 2270 /* TypeScriptModifier */ @@ -21861,13 +22798,17 @@ var ts; } // An async function declaration is ES2017 syntax. if (modifierFlags & 256 /* Async */) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // function declarations with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a FunctionDeclaration's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 2621440 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a FunctionDeclaration is generator function and is the body of a // transformed async function, then this node can be transformed to a @@ -21875,11 +22816,11 @@ var ts; // Currently we do not support transforming any other generator fucntions // down level. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592293205 /* FunctionExcludes */; + return transformFlags & ~980243797 /* FunctionExcludes */; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21892,13 +22833,17 @@ var ts; } // An async function expression is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // function expressions with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If a FunctionExpression's subtree has marked the container as needing to capture the // lexical this, or the function contains parameters with initializers, then this node is // ES6 syntax. - if (subtreeFlags & 327680 /* ES2015FunctionSyntaxMask */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 2621440 /* ES2015FunctionSyntaxMask */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a @@ -21906,14 +22851,14 @@ var ts; // Currently we do not support transforming any other generator fucntions // down level. if (node.asteriskToken && ts.getEmitFlags(node) & 2097152 /* AsyncFunctionBody */) { - transformFlags |= 6144 /* AssertGenerator */; + transformFlags |= 12288 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592293205 /* FunctionExcludes */; + return transformFlags & ~980243797 /* FunctionExcludes */; } function computeArrowFunction(node, subtreeFlags) { // An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction. - var transformFlags = subtreeFlags | 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 3072 /* AssertES2015 */; // TypeScript-specific modifiers, type parameters, and type annotations are TypeScript // syntax. if (ts.hasModifier(node, 2270 /* TypeScriptModifier */) @@ -21923,14 +22868,18 @@ var ts; } // An async arrow function is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; + } + // arrow functions with object rest destructuring are ES Next syntax + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */; } // If an ArrowFunction contains a lexical this, its container must capture the lexical this. - if (subtreeFlags & 32768 /* ContainsLexicalThis */) { - transformFlags |= 65536 /* ContainsCapturedLexicalThis */; + if (subtreeFlags & 262144 /* ContainsLexicalThis */) { + transformFlags |= 524288 /* ContainsCapturedLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~592227669 /* ArrowFunctionExcludes */; + return transformFlags & ~979719509 /* ArrowFunctionExcludes */; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21939,24 +22888,28 @@ var ts; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. if (expressionKind === 96 /* SuperKeyword */) { - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; var nameKind = node.name.kind; - // A VariableDeclaration with a binding pattern is ES6 syntax. - if (nameKind === 168 /* ObjectBindingPattern */ || nameKind === 169 /* ArrayBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + // A VariableDeclaration with an object binding pattern is ES2015 syntax + // and possibly ESNext syntax if it contains an object binding pattern + if (nameKind === 171 /* ObjectBindingPattern */) { + transformFlags |= 48 /* AssertESNext */ | 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } + else if (nameKind === 172 /* ArrayBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; } // Type annotations are TypeScript syntax. if (node.type) { transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -21968,26 +22921,22 @@ var ts; } else { transformFlags = subtreeFlags; - // If a VariableStatement is exported, then it is either ES6 or TypeScript syntax. - if (modifierFlags & 1 /* Export */) { - transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; - } - if (declarationListTransformFlags & 8388608 /* ContainsBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */; + if (declarationListTransformFlags & 67108864 /* ContainsBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */; } } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // A labeled statement containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */ + if (subtreeFlags & 33554432 /* ContainsBlockScopedBinding */ && ts.isIterationStatement(node, /*lookInLabeledStatements*/ true)) { - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -21996,18 +22945,18 @@ var ts; transformFlags |= 3 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; // If the expression of an expression statement is a destructuring assignment, // then we treat the statement as ES6 so that we can indicate that we do not // need to hold on to the right-hand side. - if (node.expression.transformFlags & 1024 /* DestructuringAssignment */) { - transformFlags |= 768 /* AssertES2015 */; + if (node.expression.transformFlags & 16384 /* DestructuringAssignment */) { + transformFlags |= 3072 /* AssertES2015 */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~536874325 /* NodeExcludes */; + return transformFlags & ~536892757 /* NodeExcludes */; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3 /* AssertTypeScript */; @@ -22016,29 +22965,29 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~574729557 /* ModuleExcludes */; + return transformFlags & ~839734613 /* ModuleExcludes */; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 33554432 /* ContainsHoistedDeclarationOrCompletion */; - if (subtreeFlags & 8388608 /* ContainsBindingPattern */) { - transformFlags |= 768 /* AssertES2015 */; + var transformFlags = subtreeFlags | 268435456 /* ContainsHoistedDeclarationOrCompletion */; + if (subtreeFlags & 67108864 /* ContainsBindingPattern */) { + transformFlags |= 3072 /* AssertES2015 */; } // If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax. if (node.flags & 3 /* BlockScoped */) { - transformFlags |= 768 /* AssertES2015 */ | 4194304 /* ContainsBlockScopedBinding */; + transformFlags |= 3072 /* AssertES2015 */ | 33554432 /* ContainsBlockScopedBinding */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; - return transformFlags & ~545262933 /* VariableDeclarationListExcludes */; + return transformFlags & ~604001621 /* VariableDeclarationListExcludes */; } function computeOther(node, kind, subtreeFlags) { // Mark transformations needed for each node var transformFlags = subtreeFlags; - var excludeFlags = 536874325 /* NodeExcludes */; + var excludeFlags = 536892757 /* NodeExcludes */; switch (kind) { case 119 /* AsyncKeyword */: - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: // async/await is ES2017 syntax - transformFlags |= 48 /* AssertES2017 */; + transformFlags |= 192 /* AssertES2017 */; break; case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: @@ -22046,84 +22995,85 @@ var ts; case 116 /* AbstractKeyword */: case 123 /* DeclareKeyword */: case 75 /* ConstKeyword */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: - case 197 /* NonNullExpression */: - case 129 /* ReadonlyKeyword */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: + case 200 /* NonNullExpression */: + case 130 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 242 /* JsxElement */: - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 245 /* JsxElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: case 10 /* JsxText */: - case 245 /* JsxClosingElement */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - case 248 /* JsxExpression */: + case 248 /* JsxClosingElement */: + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: + case 251 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 12 /* AssertJsx */; break; - case 83 /* ExportKeyword */: - // This node is both ES6 and TypeScript syntax. - transformFlags |= 768 /* AssertES2015 */ | 3 /* AssertTypeScript */; - break; - case 78 /* DefaultKeyword */: + case 212 /* ForOfStatement */: + // for-of might be ESNext if it has a rest destructuring + transformFlags |= 48 /* AssertESNext */; + // FALLTHROUGH case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: - case 190 /* TemplateExpression */: - case 177 /* TaggedTemplateExpression */: - case 254 /* ShorthandPropertyAssignment */: - case 209 /* ForOfStatement */: + case 193 /* TemplateExpression */: + case 180 /* TaggedTemplateExpression */: + case 257 /* ShorthandPropertyAssignment */: + case 114 /* StaticKeyword */: // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: // This node is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 16777216 /* ContainsYield */; + transformFlags |= 3072 /* AssertES2015 */ | 134217728 /* ContainsYield */; break; case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 142 /* TypeParameter */: - case 145 /* PropertySignature */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 155 /* TypePredicate */: - case 156 /* TypeReference */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 156 /* TypePredicate */: + case 157 /* TypeReference */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 160 /* TypeQuery */: + case 161 /* TypeLiteral */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. - transformFlags |= 2097152 /* ContainsComputedPropertyName */; - if (subtreeFlags & 32768 /* ContainsLexicalThis */) { + transformFlags |= 16777216 /* ContainsComputedPropertyName */; + if (subtreeFlags & 262144 /* ContainsLexicalThis */) { // A computed method name like `[this.getName()](x: string) { ... }` needs to // distinguish itself from the normal case of a method body containing `this`: // `this` inside a method doesn't need to be rewritten (the method provides `this`), @@ -22132,70 +23082,86 @@ var ts; // `_this = this; () => class K { [_this.getName()]() { ... } }` // To make this distinction, use ContainsLexicalThisInComputedPropertyName // instead of ContainsLexicalThis for computed property names - transformFlags |= 131072 /* ContainsLexicalThisInComputedPropertyName */; + transformFlags |= 1048576 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 192 /* SpreadElementExpression */: - // This node is ES6 syntax, but is handled by a containing node. - transformFlags |= 1048576 /* ContainsSpreadElementExpression */; + case 195 /* SpreadElement */: + case 258 /* SpreadAssignment */: + // This node is ES6 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; break; + case 173 /* BindingElement */: + if (node.dotDotDotToken) { + // this node is ES2015 or ES next syntax, but is handled by a containing node. + transformFlags |= 8388608 /* ContainsSpreadExpression */; + } case 96 /* SuperKeyword */: // This node is ES6 syntax. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; break; case 98 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; break; - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: - // These nodes are ES6 syntax. - transformFlags |= 768 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: + // These nodes are ES2015 or ES Next syntax. + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + transformFlags |= 48 /* AssertESNext */ | 67108864 /* ContainsBindingPattern */; + } + else { + transformFlags |= 3072 /* AssertES2015 */ | 67108864 /* ContainsBindingPattern */; + } break; - case 144 /* Decorator */: + case 145 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. - transformFlags |= 3 /* AssertTypeScript */ | 8192 /* ContainsDecorators */; + transformFlags |= 3 /* AssertTypeScript */ | 65536 /* ContainsDecorators */; break; - case 172 /* ObjectLiteralExpression */: - excludeFlags = 539110741 /* ObjectLiteralExcludes */; - if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { + case 175 /* ObjectLiteralExpression */: + excludeFlags = 554784085 /* ObjectLiteralExcludes */; + if (subtreeFlags & 16777216 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it // is an ES6 node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } - if (subtreeFlags & 131072 /* ContainsLexicalThisInComputedPropertyName */) { + if (subtreeFlags & 1048576 /* ContainsLexicalThisInComputedPropertyName */) { // A computed property name containing `this` might need to be rewritten, // so propagate the ContainsLexicalThis flag upward. - transformFlags |= 32768 /* ContainsLexicalThis */; + transformFlags |= 262144 /* ContainsLexicalThis */; + } + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + // If an ObjectLiteralExpression contains a spread element, then it + // is an ES next node. + transformFlags |= 48 /* AssertESNext */; } break; - case 171 /* ArrayLiteralExpression */: - case 176 /* NewExpression */: - excludeFlags = 537922901 /* ArrayLiteralOrCallOrNewExcludes */; - if (subtreeFlags & 1048576 /* ContainsSpreadElementExpression */) { - // If the this node contains a SpreadElementExpression, then it is an ES6 + case 174 /* ArrayLiteralExpression */: + case 179 /* NewExpression */: + excludeFlags = 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + if (subtreeFlags & 8388608 /* ContainsSpreadExpression */) { + // If the this node contains a SpreadExpression, then it is an ES6 // node. - transformFlags |= 768 /* AssertES2015 */; + transformFlags |= 3072 /* AssertES2015 */; } break; - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. - if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { - transformFlags |= 768 /* AssertES2015 */; + if (subtreeFlags & 33554432 /* ContainsBlockScopedBinding */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 256 /* SourceFile */: - if (subtreeFlags & 65536 /* ContainsCapturedLexicalThis */) { - transformFlags |= 768 /* AssertES2015 */; + case 260 /* SourceFile */: + if (subtreeFlags & 524288 /* ContainsCapturedLexicalThis */) { + transformFlags |= 3072 /* AssertES2015 */; } break; - case 212 /* ReturnStatement */: - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: - transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; + case 215 /* ReturnStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: + transformFlags |= 268435456 /* ContainsHoistedDeclarationOrCompletion */; break; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -22210,54 +23176,54 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 155 /* FirstTypeNode */ && kind <= 167 /* LastTypeNode */) { + if (kind >= 156 /* FirstTypeNode */ && kind <= 170 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 171 /* ArrayLiteralExpression */: - return 537922901 /* ArrayLiteralOrCallOrNewExcludes */; - case 226 /* ModuleDeclaration */: - return 574729557 /* ModuleExcludes */; - case 143 /* Parameter */: - return 545262933 /* ParameterExcludes */; - case 181 /* ArrowFunction */: - return 592227669 /* ArrowFunctionExcludes */; - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - return 592293205 /* FunctionExcludes */; - case 220 /* VariableDeclarationList */: - return 545262933 /* VariableDeclarationListExcludes */; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - return 539749717 /* ClassExcludes */; - case 149 /* Constructor */: - return 591760725 /* ConstructorExcludes */; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - return 591760725 /* MethodOrAccessorExcludes */; + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 174 /* ArrayLiteralExpression */: + return 545281365 /* ArrayLiteralOrCallOrNewExcludes */; + case 229 /* ModuleDeclaration */: + return 839734613 /* ModuleExcludes */; + case 144 /* Parameter */: + return 604001621 /* ParameterExcludes */; + case 184 /* ArrowFunction */: + return 979719509 /* ArrowFunctionExcludes */; + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + return 980243797 /* FunctionExcludes */; + case 223 /* VariableDeclarationList */: + return 604001621 /* VariableDeclarationListExcludes */; + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + return 559895893 /* ClassExcludes */; + case 150 /* Constructor */: + return 975983957 /* ConstructorExcludes */; + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return 975983957 /* MethodOrAccessorExcludes */; case 118 /* AnyKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: - case 133 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: + case 134 /* StringKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 142 /* TypeParameter */: - case 145 /* PropertySignature */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 143 /* TypeParameter */: + case 146 /* PropertySignature */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 172 /* ObjectLiteralExpression */: - return 539110741 /* ObjectLiteralExcludes */; + case 175 /* ObjectLiteralExpression */: + return 554784085 /* ObjectLiteralExcludes */; default: - return 536874325 /* NodeExcludes */; + return 536892757 /* NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -22275,25 +23241,63 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - /* @internal */ - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + /** + * Kinds of file that we are currently looking for. + * Typically there is one pass with Extensions.TypeScript, then a second pass with Extensions.JavaScript. + */ + var Extensions; + (function (Extensions) { + Extensions[Extensions["TypeScript"] = 0] = "TypeScript"; + Extensions[Extensions["JavaScript"] = 1] = "JavaScript"; + Extensions[Extensions["DtsOnly"] = 2] = "DtsOnly"; /** Only '.d.ts' */ + })(Extensions || (Extensions = {})); + /** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */ + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + /** Create Resolved from a file with unknown extension. */ + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2 /* DtsOnly */: + case 0 /* TypeScript */: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1 /* JavaScript */: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -22302,19 +23306,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - // Use the main module for inferring types if no types package specified and the allowJs is set - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -22326,7 +23317,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -22355,11 +23345,11 @@ var ts; if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); } - var parent_7 = ts.getDirectoryPath(currentDirectory); - if (parent_7 === currentDirectory) { + var parent_6 = ts.getDirectoryPath(currentDirectory); + if (parent_6 === currentDirectory) { break; } - currentDirectory = parent_7; + currentDirectory = parent_6; } return typeRoots; } @@ -22374,7 +23364,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -22402,18 +23391,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2 /* DtsOnly */, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -22425,16 +23413,13 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { // check secondary locations if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2 /* DtsOnly */, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*checkOneLevel*/ false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -22450,9 +23435,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -22475,8 +23458,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -22593,15 +23576,15 @@ var ts; * be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remaining * entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location. */ - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -22639,7 +23622,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -22658,7 +23641,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -22669,7 +23652,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -22697,9 +23680,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -22709,46 +23692,56 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, /*checkOneLevel*/ false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } /* @internal */ function directoryProbablyExists(directoryName, host) { @@ -22760,9 +23753,9 @@ var ts; * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -22774,11 +23767,11 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing var directory = ts.getDirectoryPath(candidate); @@ -22786,9 +23779,18 @@ var ts; onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2 /* DtsOnly */: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0 /* TypeScript */: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1 /* JavaScript */: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } /** Return the file if it exists. */ function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { @@ -22813,19 +23815,23 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); // A package.json "typings" may specify an exact filename, or may choose to omit an extension. - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + // Note: this would allow a package.json to specify a ".js" file as typings. Maybe that should be forbidden. + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0 /* TypeScript */, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -22836,91 +23842,78 @@ var ts; // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - /* @internal */ - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, /*typesOnly*/ false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); + return loadModuleFromNodeModulesWorker(0 /* TypeScript */, moduleName, directory, failedLookupLocations, state, /*checkOneLevel*/ false, /*typesOnly*/ true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - // Try to load source from the package - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - // Always prefer a TypeScript (.ts, .tsx, .d.ts) file shipped with the package - return packageResult; - } - } - // Else prefer a types package over non-TypeScript results (e.g. JavaScript files) - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/ false, failedLookupLocations); + var resolved = tryResolve(0 /* TypeScript */) || tryResolve(1 /* JavaScript */); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0 /* TypeScript */) { + // If we didn't find the file normally, look it up in @types. + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - // If we didn't find the file normally, look it up in @types. - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; /** Climb up parent directories looking for a module. */ - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -22931,6 +23924,23 @@ var ts; containingDirectory = parentPath; } } + /** + * LSHost may load a module from a global cache of typings. + * This is the minumum code needed to expose that functionality; the rest is in LSHost. + */ + /* @internal */ + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0 /* TypeScript */, moduleName, globalCache, failedLookupLocations, state, /*checkOneLevel*/ true) || + loadModuleFromNodeModules(1 /* JavaScript */, moduleName, globalCache, failedLookupLocations, state, /*checkOneLevel*/ true); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); /// /// @@ -23030,7 +24040,12 @@ var ts; getAmbientModules: getAmbientModules, getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter + isOptionalParameter: isOptionalParameter, + tryFindAmbientModuleWithoutAugmentations: function (moduleName) { + // we deliberately exclude augmentations + // since we are only interested in declarations of the module itself + return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); + } }; var tupleTypes = []; var unionTypes = ts.createMap(); @@ -23044,9 +24059,9 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var undefinedType = createIntrinsicType(2048 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 524288 /* ContainsWideningType */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(2048 /* Undefined */ | 2097152 /* ContainsWideningType */, "undefined"); var nullType = createIntrinsicType(4096 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 /* Null */ | 524288 /* ContainsWideningType */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(4096 /* Null */ | 2097152 /* ContainsWideningType */, "null"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var trueType = createIntrinsicType(128 /* BooleanLiteral */, "true"); @@ -23056,13 +24071,17 @@ var ts; var voidType = createIntrinsicType(1024 /* Void */, "void"); var neverType = createIntrinsicType(8192 /* Never */, "never"); var silentNeverType = createIntrinsicType(8192 /* Never */, "never"); + var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); + var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */ | 67108864 /* Transient */, "__type"); + emptyTypeLiteralSymbol.members = ts.createMap(); + var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.flags |= 2097152 /* ContainsAnyFunctionType */; + anyFunctionType.flags |= 8388608 /* ContainsAnyFunctionType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); @@ -23221,6 +24240,8 @@ var ts; "undefined": undefinedType }); var jsxElementType; + var _jsxNamespace; + var _jsxFactoryEntity; /** Things we lazy load from the JSX namespace */ var jsxTypes = ts.createMap(); var JsxNames = { @@ -23250,6 +24271,21 @@ var ts; builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); return checker; + function getJsxNamespace() { + if (_jsxNamespace === undefined) { + _jsxNamespace = "React"; + if (compilerOptions.jsxFactory) { + _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + if (_jsxFactoryEntity) { + _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).text; + } + } + else if (compilerOptions.reactNamespace) { + _jsxNamespace = compilerOptions.reactNamespace; + } + } + return _jsxNamespace; + } function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. @@ -23333,7 +24369,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 226 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 226 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 229 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 229 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -23395,7 +24431,7 @@ var ts; var moduleNotFoundError = !ts.isInAmbientContext(moduleName.parent.parent) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; - var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError); + var mainModule = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); if (!mainModule) { return; } @@ -23440,7 +24476,7 @@ var ts; return type.flags & 32768 /* Object */ ? type.objectFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 256 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 260 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -23497,7 +24533,7 @@ var ts; if (declaration.pos <= usage.pos) { // declaration is before usage // still might be illegal if usage is in the initializer of the variable declaration - return declaration.kind !== 219 /* VariableDeclaration */ || + return declaration.kind !== 222 /* VariableDeclaration */ || !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } // declaration is after usage @@ -23507,9 +24543,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 201 /* VariableStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 204 /* VariableStatement */: + case 210 /* ForStatement */: + case 212 /* 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, container)) { @@ -23518,8 +24554,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -23537,7 +24573,7 @@ var ts; return true; } var initializerOfNonStaticProperty = current.parent && - current.parent.kind === 146 /* PropertyDeclaration */ && + current.parent.kind === 147 /* PropertyDeclaration */ && (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { @@ -23570,11 +24606,11 @@ 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 & 793064 /* Type */ && lastLocation.kind !== 273 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 277 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 143 /* Parameter */ || - lastLocation.kind === 142 /* TypeParameter */ + lastLocation.kind === 144 /* Parameter */ || + lastLocation.kind === 143 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -23583,9 +24619,9 @@ 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 === 143 /* Parameter */ || + lastLocation.kind === 144 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 143 /* Parameter */); + result.valueDeclaration.kind === 144 /* Parameter */); } } if (useResult) { @@ -23597,13 +24633,13 @@ var ts; } } switch (location.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 256 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 260 /* SourceFile */ || ts.isAmbientModule(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["default"]) { @@ -23626,7 +24662,7 @@ var ts; // which is not the desired behavior. if (moduleExports[name] && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 239 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 242 /* ExportSpecifier */)) { break; } } @@ -23634,13 +24670,13 @@ var ts; break loop; } break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: // 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 @@ -23657,9 +24693,9 @@ var ts; } } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (lastLocation && ts.getModifierFlags(lastLocation) & 32 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -23670,7 +24706,7 @@ var ts; } break loop; } - if (location.kind === 193 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 196 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23686,9 +24722,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 226 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -23696,19 +24732,19 @@ var ts; } } break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -23721,7 +24757,7 @@ var ts; } } break; - case 144 /* Decorator */: + case 145 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -23730,7 +24766,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 === 143 /* Parameter */) { + if (location.parent && location.parent.kind === 144 /* Parameter */) { location = location.parent; } // @@ -23793,7 +24829,7 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 229 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 232 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23847,9 +24883,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23871,7 +24907,7 @@ var ts; // Block-scoped variables cannot be used before their definition var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 219 /* VariableDeclaration */), errorLocation)) { + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 222 /* VariableDeclaration */), errorLocation)) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); } } @@ -23892,10 +24928,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 230 /* ImportEqualsDeclaration */) { + if (node.kind === 233 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 231 /* ImportDeclaration */) { + while (node && node.kind !== 234 /* ImportDeclaration */) { node = node.parent; } return node; @@ -23905,7 +24941,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 241 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 244 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); @@ -23984,31 +25020,31 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_13 = specifier.propertyName || specifier.name; - if (name_13.text) { + var name_17 = specifier.propertyName || specifier.name; + if (name_17.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_13.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_17.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_13.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_17.text); } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_13.text); + var symbolFromModule = getExportOfModule(targetSymbol, name_17.text); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromModule && allowSyntheticDefaultImports && name_13.text === "default") { + if (!symbolFromModule && allowSyntheticDefaultImports && name_17.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_13, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_13)); + error(name_17, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_17)); } return symbol; } @@ -24030,19 +25066,19 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return getTargetOfImportClause(node); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return getTargetOfExportAssignment(node); - case 229 /* NamespaceExportDeclaration */: + case 232 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node); } } @@ -24089,11 +25125,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 236 /* ExportAssignment */) { + if (node.kind === 239 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 239 /* ExportSpecifier */) { + else if (node.kind === 242 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -24115,13 +25151,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 140 /* QualifiedName */) { + if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 141 /* 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 === 230 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 233 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -24141,9 +25177,9 @@ var ts; return undefined; } } - else if (name.kind === 140 /* QualifiedName */ || name.kind === 173 /* PropertyAccessExpression */) { - var left = name.kind === 140 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 140 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 141 /* QualifiedName */ || name.kind === 176 /* PropertyAccessExpression */) { + var left = name.kind === 141 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 141 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24168,30 +25204,30 @@ var ts; function resolveExternalModuleName(location, moduleReferenceExpression) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ts.Diagnostics.Cannot_find_module_0); } - function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError) { + function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; - return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral); + return resolveExternalModule(location, moduleReferenceLiteral.text, moduleNotFoundError, moduleReferenceLiteral, isForAugmentation); } - function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode) { + function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + if (isForAugmentation === void 0) { isForAugmentation = false; } // Module names are escaped in our symbol table. However, string literal values aren't. // Escape the name in the "require(...)" clause to ensure we find the right symbol. var moduleName = ts.escapeIdentifier(moduleReference); if (moduleName === undefined) { return; } - var isRelative = ts.isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); - if (symbol) { - // merged symbol is module declaration symbol combined with all augmentations - return getMergedSymbol(symbol); - } + var ambientModule = tryFindAmbientModule(moduleName, /*withAugmentations*/ true); + if (ambientModule) { + return ambientModule; } + var isRelative = ts.isExternalModuleNameRelative(moduleName); var resolvedModule = ts.getResolvedModule(ts.getSourceFileOfNode(location), moduleReference); - var sourceFile = resolvedModule && host.getSourceFile(resolvedModule.resolvedFileName); + var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); + var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { if (sourceFile.symbol) { // merged symbol is module declaration symbol combined with all augmentations @@ -24209,15 +25245,33 @@ var ts; return getMergedSymbol(pattern.symbol); } } + // May be an untyped module. If so, ignore resolutionDiagnostic. + if (!isRelative && resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (isForAugmentation) { + ts.Debug.assert(!!moduleNotFoundError); + var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; + error(errorNode, diag, moduleName, resolvedModule.resolvedFileName); + } + else if (compilerOptions.noImplicitAny && moduleNotFoundError) { + error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + } + // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. + return undefined; + } if (moduleNotFoundError) { // report errors only if it was requested - var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); - if (tsExtension) { - var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + if (resolutionDiagnostic) { + error(errorNode, resolutionDiagnostic, moduleName, resolvedModule.resolvedFileName); } else { - error(errorNode, moduleNotFoundError, moduleName); + var tsExtension = ts.tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, ts.removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } } return undefined; @@ -24350,7 +25404,7 @@ var ts; var members = node.members; for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { var member = members_1[_i]; - if (member.kind === 149 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 150 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -24426,11 +25480,11 @@ var ts; } } switch (location_1.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location_1)) { break; } - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } @@ -24471,7 +25525,7 @@ var ts; return ts.forEachProperty(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -24510,7 +25564,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 239 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 242 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24525,10 +25579,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: continue; default: return false; @@ -24609,7 +25663,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -24650,12 +25704,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 159 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 160 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 140 /* QualifiedName */ || entityName.kind === 173 /* PropertyAccessExpression */ || - entityName.parent.kind === 230 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 141 /* QualifiedName */ || entityName.kind === 176 /* PropertyAccessExpression */ || + entityName.parent.kind === 233 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -24751,10 +25805,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 165 /* ParenthesizedType */) { + while (node.kind === 166 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 227 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -24762,7 +25816,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 227 /* ModuleBlock */ && + node.parent.kind === 230 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24776,10 +25830,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return "(Anonymous class)"; - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -24854,9 +25908,9 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + walkSymbol(parent_7, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } if (accessibleSymbolChain) { @@ -24918,31 +25972,8 @@ var ts; // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); } - else if (!(flags & 512 /* InTypeAlias */) && - (getObjectFlags(type) & 16 /* Anonymous */ && !type.target || type.flags & 196608 /* UnionOrIntersection */) && - type.aliasSymbol && + else if (!(flags & 512 /* InTypeAlias */) && (getObjectFlags(type) & 16 /* Anonymous */ || type.flags & 196608 /* UnionOrIntersection */) && type.aliasSymbol && isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) { - // We emit inferred type as type-alias if type is not in type-alias declaration, existed accessible alias-symbol, type is anonymous or union or intersection. - // However, if the type is an anonymous type with type arguments, we need to perform additional check. - // 1) No type arguments, just emit type-alias as is - // 2) Existed type arguments, check if the type arguments full fill all type parameters of the alias-symbol by - // checking whether the target's aliasTypeArguments has the same size as type's aliasTypeArguments: - // i.e - // type Foo = { - // foo(): Foo - // }; - // function foo() { - // return {} as Foo; - // } - // Should be emitted as - // declare type Foo = { - // foo(): Foo; - // }; - // declare function foo(): Foo; - // Otherwise type-alias is point to another generic type-alias then don't write it using alias symbol - // export type Bar = () => [X, Y]; - // export type Foo = Bar; - // export const y = (x: Foo) => 1 // this should be emit as "export declare const y: (x: () => [any, string]) => number;" var typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); } @@ -24955,6 +25986,17 @@ var ts; else if (type.flags & 96 /* StringOrNumberLiteral */) { writer.writeStringLiteral(literalTypeToString(type)); } + else if (type.flags & 262144 /* Index */) { + writer.writeKeyword("keyof"); + writeSpace(writer); + writeType(type.type, 64 /* InElementType */); + } + else if (type.flags & 524288 /* IndexedAccess */) { + writeType(type.objectType, 64 /* InElementType */); + writePunctuation(writer, 20 /* OpenBracketToken */); + writeType(type.indexType, 0 /* None */); + writePunctuation(writer, 21 /* CloseBracketToken */); + } else { // Should never get here // { ... } @@ -25018,14 +26060,14 @@ var ts; while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; - var parent_9 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_8 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_9); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_8); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_9, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_8, typeArguments, start, i, flags); writePunctuation(writer, 22 /* DotToken */); } } @@ -25061,9 +26103,7 @@ var ts; else if (ts.contains(symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name var typeAlias = getTypeAliasForTypeLiteral(type); - // We only want to use type-alias here if the typeAlias is not a generic one. (i.e it doesn't have a target type) - // If it is a generic type-alias just write out "any" - if (typeAlias && !type.target) { + if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } @@ -25093,7 +26133,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 256 /* SourceFile */ || declaration.parent.kind === 227 /* ModuleBlock */; + return declaration.parent.kind === 260 /* SourceFile */ || declaration.parent.kind === 230 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -25110,7 +26150,7 @@ var ts; function writeIndexSignature(info, keyword) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } writePunctuation(writer, 20 /* OpenBracketToken */); @@ -25128,7 +26168,7 @@ var ts; } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 129 /* ReadonlyKeyword */); + writeKeyword(writer, 130 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); @@ -25185,6 +26225,12 @@ var ts; writePunctuation(writer, 16 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, 17 /* CloseBraceToken */); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); @@ -25197,8 +26243,8 @@ var ts; writePunctuation(writer, 24 /* SemicolonToken */); writer.writeLine(); } - writeIndexSignature(resolved.stringIndexInfo, 133 /* StringKeyword */); - writeIndexSignature(resolved.numberIndexInfo, 131 /* NumberKeyword */); + writeIndexSignature(resolved.stringIndexInfo, 134 /* StringKeyword */); + writeIndexSignature(resolved.numberIndexInfo, 132 /* NumberKeyword */); for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); @@ -25221,9 +26267,6 @@ var ts; writer.writeLine(); } } - writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); - inObjectTypeLiteral = saveInObjectTypeLiteral; } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -25262,12 +26305,12 @@ var ts; } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 171 /* ObjectBindingPattern */) { writePunctuation(writer, 16 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); writePunctuation(writer, 17 /* CloseBraceToken */); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 172 /* ArrayBindingPattern */) { writePunctuation(writer, 20 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); @@ -25281,7 +26324,7 @@ var ts; if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 170 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 173 /* BindingElement */); if (bindingElement.propertyName) { writer.writeSymbol(ts.getTextOfNode(bindingElement.propertyName), bindingElement.symbol); writePunctuation(writer, 55 /* ColonToken */); @@ -25411,75 +26454,75 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 170 /* BindingElement */: + case 173 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 221 /* FunctionDeclaration */: - case 225 /* EnumDeclaration */: - case 230 /* ImportEqualsDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 224 /* FunctionDeclaration */: + case 228 /* EnumDeclaration */: + case 233 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_10 = getDeclarationContainer(node); + var parent_9 = 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 !== 230 /* ImportEqualsDeclaration */ && parent_10.kind !== 256 /* SourceFile */ && ts.isInAmbientContext(parent_10))) { - return isGlobalSourceFile(parent_10); + !(node.kind !== 233 /* ImportEqualsDeclaration */ && parent_9.kind !== 260 /* SourceFile */ && ts.isInAmbientContext(parent_9))) { + return isGlobalSourceFile(parent_9); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible - return isDeclarationVisible(parent_10); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + return isDeclarationVisible(parent_9); + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.getModifierFlags(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 const it fall into next case statement - case 149 /* Constructor */: - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 154 /* IndexSignature */: - case 143 /* Parameter */: - case 227 /* ModuleBlock */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 156 /* TypeReference */: - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: + case 150 /* Constructor */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 155 /* IndexSignature */: + case 144 /* Parameter */: + case 230 /* ModuleBlock */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 157 /* TypeReference */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: return false; // Type parameters are always visible - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: // Source file and namespace export are always visible - case 256 /* SourceFile */: - case 229 /* NamespaceExportDeclaration */: + case 260 /* SourceFile */: + case 232 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return false; default: return false; @@ -25488,10 +26531,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 239 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 239 /* ExportSpecifier */) { + else if (node.parent.kind === 242 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -25584,12 +26627,12 @@ var ts; node = ts.getRootDeclaration(node); while (node) { switch (node.kind) { - case 219 /* VariableDeclaration */: - case 220 /* VariableDeclarationList */: - case 235 /* ImportSpecifier */: - case 234 /* NamedImports */: - case 233 /* NamespaceImport */: - case 232 /* ImportClause */: + case 222 /* VariableDeclaration */: + case 223 /* VariableDeclarationList */: + case 238 /* ImportSpecifier */: + case 237 /* NamedImports */: + case 236 /* NamespaceImport */: + case 235 /* ImportClause */: node = node.parent; break; default: @@ -25622,22 +26665,30 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } - function getTextOfPropertyName(name) { - switch (name.kind) { - case 70 /* Identifier */: - return name.text; - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - return name.text; - case 141 /* ComputedPropertyName */: - if (ts.isStringOrNumericLiteral(name.expression.kind)) { - return name.expression.text; - } - } - return undefined; - } function isComputedNonLiteralName(name) { - return name.kind === 141 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression.kind); + } + function getRestType(source, properties, symbol) { + ts.Debug.assert(!!(source.flags & 32768 /* Object */), "Rest types only support object types right now."); + var members = ts.createMap(); + var names = ts.createMap(); + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var name_18 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_18)] = true; + } + for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { + var prop = _b[_a]; + var inNamesToRemove = prop.name in names; + var isPrivate = getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */); + var isMethod = prop.flags & 8192 /* Method */; + var isSetOnlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (!inNamesToRemove && !isPrivate && !isMethod && !isSetOnlyAccessor) { + members[prop.name] = prop; + } + } + var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); + var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); + return createAnonymousType(symbol, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { @@ -25657,25 +26708,41 @@ var ts; return parentType; } var type; - if (pattern.kind === 168 /* ObjectBindingPattern */) { - // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_14 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_14)) { - // computed properties with non-literal names are treated as 'any' - return anyType; + if (pattern.kind === 171 /* ObjectBindingPattern */) { + if (declaration.dotDotDotToken) { + if (!(parentType.flags & 32768 /* Object */)) { + error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); + return unknownType; + } + var literalMembers = []; + for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (element.kind !== 197 /* OmittedExpression */ && !element.dotDotDotToken) { + literalMembers.push(element.propertyName || element.name); + } + } + type = getRestType(parentType, literalMembers, declaration.symbol); } - if (declaration.initializer) { - getContextualType(declaration.initializer); - } - // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, - // or otherwise the type of the string index signature. - var text = getTextOfPropertyName(name_14); - type = getTypeOfPropertyOfType(parentType, text) || - isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || - getIndexTypeOfType(parentType, 0 /* String */); - if (!type) { - error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_14)); - return unknownType; + else { + // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) + var name_19 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_19)) { + // computed properties with non-literal names are treated as 'any' + return anyType; + } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } + // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, + // or otherwise the type of the string index signature. + var text = ts.getTextOfPropertyName(name_19); + type = getTypeOfPropertyOfType(parentType, text) || + isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1 /* Number */) || + getIndexTypeOfType(parentType, 0 /* String */); + if (!type) { + error(name_19, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_19)); + return unknownType; + } } } else { @@ -25683,7 +26750,11 @@ var ts; // 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(parentType, pattern, /*allowStringInput*/ false); - if (!declaration.dotDotDotToken) { + if (declaration.dotDotDotToken) { + // Rest element has an array type with the same element type as the parent type + type = createArrayType(elementType); + } + else { // Use specific property type when parent is a tuple or numeric index type when parent is an array var propName = "" + ts.indexOf(pattern.elements, declaration); type = isTupleLikeType(parentType) @@ -25699,10 +26770,6 @@ var ts; return unknownType; } } - else { - // Rest element has an array type with the same element type as the parent type - type = createArrayType(elementType); - } } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. @@ -25725,16 +26792,16 @@ var ts; if (typeTag && typeTag.typeExpression) { return typeTag.typeExpression.type; } - if (declaration.kind === 219 /* VariableDeclaration */ && - declaration.parent.kind === 220 /* VariableDeclarationList */ && - declaration.parent.parent.kind === 201 /* VariableStatement */) { + if (declaration.kind === 222 /* VariableDeclaration */ && + declaration.parent.kind === 223 /* VariableDeclarationList */ && + declaration.parent.parent.kind === 204 /* VariableStatement */) { // @type annotation might have been on the variable statement, try that instead. var annotation = ts.getJSDocTypeTag(declaration.parent.parent); if (annotation && annotation.typeExpression) { return annotation.typeExpression.type; } } - else if (declaration.kind === 143 /* Parameter */) { + else if (declaration.kind === 144 /* Parameter */) { // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); @@ -25750,14 +26817,14 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 171 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 174 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. @@ -25767,10 +26834,10 @@ var ts; } } // A variable declared in a for..in statement is always of type string - if (declaration.parent.parent.kind === 208 /* ForInStatement */) { + if (declaration.parent.parent.kind === 211 /* ForInStatement */) { return stringType; } - if (declaration.parent.parent.kind === 209 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 212 /* 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, @@ -25784,7 +26851,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - if (declaration.kind === 219 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + if (declaration.kind === 222 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // Use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -25797,11 +26864,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 143 /* Parameter */) { + if (declaration.kind === 144 /* Parameter */) { 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 === 151 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 150 /* GetAccessor */); + if (func.kind === 152 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 151 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25831,7 +26898,7 @@ var ts; return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 254 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 257 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -25862,12 +26929,12 @@ var ts; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name)) { - // do not include computed properties in the implied type + if (isComputedNonLiteralName(name) || e.dotDotDotToken) { + // do not include computed properties or rests in the implied type hasComputedProperties = true; return; } - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); @@ -25907,7 +26974,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 168 /* ObjectBindingPattern */ + return pattern.kind === 171 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25929,7 +26996,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - if (declaration.kind === 253 /* PropertyAssignment */) { + if (declaration.kind === 256 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -25946,7 +27013,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 143 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 144 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25962,10 +27029,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 236 /* ExportAssignment */) { + if (declaration.kind === 239 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 1048576 /* JavaScriptFile */ && declaration.kind === 280 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 2097152 /* JavaScriptFile */ && declaration.kind === 284 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -25978,16 +27045,16 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 188 /* BinaryExpression */ || - declaration.kind === 173 /* PropertyAccessExpression */ && declaration.parent.kind === 188 /* BinaryExpression */) { + if (declaration.kind === 191 /* BinaryExpression */ || + declaration.kind === 176 /* PropertyAccessExpression */ && declaration.parent.kind === 191 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var typeTag = ts.getJSDocTypeTag(declaration.parent); if (typeTag && typeTag.typeExpression) { return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); } } - var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 188 /* BinaryExpression */ ? + var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 191 /* BinaryExpression */ ? checkExpressionCached(decl.right) : checkExpressionCached(decl.parent.right); }); type = getUnionType(declaredTypes, /*subtypeReduction*/ true); @@ -26015,7 +27082,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 150 /* GetAccessor */) { + if (accessor.kind === 151 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -26035,9 +27102,9 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 151 /* SetAccessor */); - if (getter && getter.flags & 1048576 /* JavaScriptFile */) { + var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); + if (getter && getter.flags & 2097152 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -26080,7 +27147,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 150 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); error(getter_1, 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)); } } @@ -26091,7 +27158,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.valueDeclaration.kind === 226 /* ModuleDeclaration */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } else { @@ -26187,9 +27254,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 222 /* ClassDeclaration */ || node.kind === 193 /* ClassExpression */ || - node.kind === 221 /* FunctionDeclaration */ || node.kind === 180 /* FunctionExpression */ || - node.kind === 148 /* MethodDeclaration */ || node.kind === 181 /* ArrowFunction */) { + if (node.kind === 225 /* ClassDeclaration */ || node.kind === 196 /* ClassExpression */ || + node.kind === 224 /* FunctionDeclaration */ || node.kind === 183 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */ || node.kind === 184 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -26199,7 +27266,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, 223 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 226 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -26208,8 +27275,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 223 /* InterfaceDeclaration */ || node.kind === 222 /* ClassDeclaration */ || - node.kind === 193 /* ClassExpression */ || node.kind === 224 /* TypeAliasDeclaration */) { + if (node.kind === 226 /* InterfaceDeclaration */ || node.kind === 225 /* ClassDeclaration */ || + node.kind === 196 /* ClassExpression */ || node.kind === 227 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -26352,7 +27419,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 226 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -26384,7 +27451,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 223 /* InterfaceDeclaration */) { + if (declaration.kind === 226 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -26442,7 +27509,7 @@ var ts; return unknownType; } var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - var declaration = ts.getDeclarationOfKind(symbol, 279 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 283 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -26453,7 +27520,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 224 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 227 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type, symbol, typeParameters); } if (popTypeResolution()) { @@ -26479,14 +27546,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 189 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || expr.kind === 70 /* Identifier */ && !!symbol.exports[expr.text]; } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225 /* EnumDeclaration */) { + if (declaration.kind === 228 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -26514,7 +27581,7 @@ var ts; var memberTypes = ts.createMap(); for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 225 /* EnumDeclaration */) { + if (declaration.kind === 228 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -26552,7 +27619,7 @@ var ts; if (!links.declaredType) { var type = createType(16384 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -26606,19 +27673,19 @@ var ts; function isIndependentType(node) { switch (node.kind) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: - case 128 /* NeverKeyword */: - case 167 /* LiteralType */: + case 129 /* NeverKeyword */: + case 170 /* LiteralType */: return true; - case 161 /* ArrayType */: + case 162 /* ArrayType */: return isIndependentType(node.elementType); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -26631,7 +27698,7 @@ var ts; // A function-like declaration is considered independent (free of this references) if it has a return type // annotation that is considered independent and if each parameter is considered independent. function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 149 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 150 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -26652,12 +27719,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -26725,8 +27792,8 @@ var ts; else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); - callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); - constructSignatures = instantiateList(source.declaredConstructSignatures, mapper, instantiateSignature); + callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper); + constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper); stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper); numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper); } @@ -26788,7 +27855,7 @@ var ts; var baseSig = baseSignatures_1[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { - var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -26893,6 +27960,9 @@ var ts; function intersectIndexInfos(info1, info2) { return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly); } + function unionSpreadIndexInfos(info1, info2) { + return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly); + } function resolveIntersectionTypeMembers(type) { // The members and properties collections are empty for intersection types. To get all properties of an // intersection type use getPropertiesOfType (only the language service uses this). @@ -26913,8 +27983,8 @@ var ts; var symbol = type.symbol; if (type.target) { var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateList(getSignaturesOfType(type.target, 0 /* Call */), type.mapper, instantiateSignature); - var constructSignatures = instantiateList(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper, instantiateSignature); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0 /* String */), type.mapper); var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1 /* Number */), type.mapper); setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); @@ -27026,7 +28096,9 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 196608 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); + return type.flags & 196608 /* UnionOrIntersection */ ? + getPropertiesOfUnionOrIntersectionType(type) : + getPropertiesOfObjectType(type); } /** * The apparent type of a type parameter is the base constraint instantiated with the type parameter @@ -27048,22 +28120,13 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - if (type.flags & 16384 /* TypeParameter */) { - type = getApparentTypeOfTypeParameter(type); - } - if (type.flags & 34 /* StringLike */) { - type = globalStringType; - } - else if (type.flags & 340 /* NumberLike */) { - type = globalNumberType; - } - else if (type.flags & 136 /* BooleanLike */) { - type = globalBooleanType; - } - else if (type.flags & 512 /* ESSymbol */) { - type = getGlobalESSymbolType(); - } - return type; + var t = type.flags & 16384 /* TypeParameter */ ? getApparentTypeOfTypeParameter(type) : type; + return t.flags & 34 /* StringLike */ ? globalStringType : + t.flags & 340 /* NumberLike */ ? globalNumberType : + t.flags & 136 /* BooleanLike */ ? globalBooleanType : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 262144 /* Index */ ? stringOrNumberType : + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -27227,7 +28290,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -27257,8 +28320,8 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 1048576 /* JavaScriptFile */) { - if (node.type && node.type.kind === 268 /* JSDocOptionalType */) { + if (node.flags & 2097152 /* JavaScriptFile */) { + if (node.type && node.type.kind === 272 /* JSDocOptionalType */) { return true; } var paramTag = ts.getCorrespondingJSDocParameterTag(node); @@ -27267,11 +28330,19 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 268 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 272 /* JSDocOptionalType */; } } } } + function tryFindAmbientModule(moduleName, withAugmentations) { + if (ts.isExternalModuleNameRelative(moduleName)) { + return undefined; + } + var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + // merged symbol is module declaration symbol combined with all augmentations + return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; + } function isOptionalParameter(node) { if (ts.hasQuestionToken(node) || isJSDocOptionalParameter(node)) { return true; @@ -27329,7 +28400,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 167 /* LiteralType */) { + if (param.type && param.type.kind === 170 /* LiteralType */) { hasLiteralTypes = true; } if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) { @@ -27343,10 +28414,10 @@ 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 === 150 /* GetAccessor */ || declaration.kind === 151 /* SetAccessor */) && + if ((declaration.kind === 151 /* GetAccessor */ || declaration.kind === 152 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; + var otherKind = declaration.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); @@ -27358,14 +28429,14 @@ var ts; if (isJSConstructSignature) { minArgumentCount--; } - var classType = declaration.kind === 149 /* Constructor */ ? + var classType = declaration.kind === 150 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 155 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 156 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -27382,7 +28453,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 1048576 /* JavaScriptFile */) { + if (declaration.flags & 2097152 /* JavaScriptFile */) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -27390,8 +28461,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 150 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 151 /* SetAccessor */); + if (declaration.kind === 151 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 152 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27405,20 +28476,20 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 273 /* JSDocFunctionType */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -27489,6 +28560,11 @@ var ts; return anyType; } function getSignatureInstantiation(signature, typeArguments) { + var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); + var id = getTypeListId(typeArguments); + return instantiations[id] || (instantiations[id] = createSignatureInstantiation(signature, typeArguments)); + } + function createSignatureInstantiation(signature, typeArguments) { return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); } function getErasedSignature(signature) { @@ -27505,7 +28581,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 149 /* Constructor */ || signature.declaration.kind === 153 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 150 /* Constructor */ || signature.declaration.kind === 154 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -27519,7 +28595,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 131 /* NumberKeyword */ : 133 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 134 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -27546,7 +28622,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 142 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 143 /* TypeParameter */).constraint; } function hasConstraintReferenceTo(type, target) { var checked; @@ -27579,7 +28655,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 142 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 143 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -27616,7 +28692,7 @@ var ts; result |= type.flags; } } - return result & 3670016 /* PropagatingFlags */; + return result & 14680064 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -27692,11 +28768,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: return node.typeName; - case 267 /* JSDocTypeReference */: + case 271 /* JSDocTypeReference */: return node.name; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -27722,7 +28798,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 267 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 271 /* JSDocTypeReference */) { // A JSDocTypeReference may have resolved to a value (as opposed to a type). In // that case, the type of this reference is just the type of the value we resolved // to. @@ -27735,14 +28811,14 @@ var ts; if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 267 /* JSDocTypeReference */) { + if (node.kind === 271 /* JSDocTypeReference */) { var typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(typeReferenceName); type = getTypeReferenceType(node, symbol); } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 156 /* TypeReference */ + var typeNameOrExpression = node.kind === 157 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27777,9 +28853,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: return declaration; } } @@ -27934,7 +29010,7 @@ var ts; typeSet.containsUndefined = true; if (flags & 4096 /* Null */) typeSet.containsNull = true; - if (!(flags & 524288 /* ContainsWideningType */)) + if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } else if (!(flags & 8192 /* Never */)) { @@ -28012,7 +29088,7 @@ var ts; var t = types[i]; var remove = t.flags & 32 /* StringLiteral */ && types.containsString || t.flags & 64 /* NumberLiteral */ && types.containsNumber || - t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 262144 /* FreshLiteral */ && containsType(types, t.regularType); + t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 1048576 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -28109,7 +29185,7 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var _loop_1 = function (i) { + var _loop_2 = function (i) { var type_1 = types[i]; if (type_1.flags & 65536 /* Union */) { return { value: getUnionType(ts.map(type_1.types, function (t) { return getIntersectionType(ts.replaceElement(types, i, t)); }), @@ -28117,7 +29193,7 @@ var ts; } }; for (var i = 0; i < types.length; i++) { - var state_2 = _loop_1(i); + var state_2 = _loop_2(i); if (typeof state_2 === "object") return state_2.value; } @@ -28147,26 +29223,223 @@ var ts; } return links.resolvedType; } + function getIndexTypeForTypeParameter(type) { + if (!type.resolvedIndexType) { + type.resolvedIndexType = createType(262144 /* Index */); + type.resolvedIndexType.type = type; + } + return type.resolvedIndexType; + } + function getLiteralTypeFromPropertyName(prop) { + return ts.startsWith(prop.name, "__@") ? neverType : getLiteralTypeForText(32 /* StringLiteral */, ts.unescapeIdentifier(prop.name)); + } + function getLiteralTypeFromPropertyNames(type) { + return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName)); + } + function getIndexType(type) { + return type.flags & 16384 /* TypeParameter */ ? getIndexTypeForTypeParameter(type) : + type.flags & 1 /* Any */ || getIndexInfoOfType(type, 0 /* String */) ? stringOrNumberType : + getIndexInfoOfType(type, 1 /* Number */) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getLiteralTypeFromPropertyNames(type); + } + function getTypeFromTypeOperatorNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexType(getTypeFromTypeNodeNoAlias(node.type)); + } + return links.resolvedType; + } + function createIndexedAccessType(objectType, indexType) { + var type = createType(524288 /* IndexedAccess */); + type.objectType = objectType; + type.indexType = indexType; + return type; + } + function getIndexedAccessTypeForTypeParameter(objectType, indexType) { + var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); + return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); + } + function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { + var accessExpression = accessNode && accessNode.kind === 177 /* ElementAccessExpression */ ? accessNode : undefined; + var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? + indexType.text : + accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? + ts.getPropertyNameForKnownSymbolName(accessExpression.argumentExpression.name.text) : + undefined; + if (propName) { + var prop = getPropertyOfType(objectType, propName); + if (prop) { + if (accessExpression) { + if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { + error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); + return unknownType; + } + if (cacheSymbol) { + getNodeLinks(accessNode).resolvedSymbol = prop; + } + } + return getTypeOfSymbol(prop); + } + } + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */)) { + if (isTypeAny(objectType)) { + return anyType; + } + var indexInfo = isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + getIndexInfoOfType(objectType, 0 /* String */) || + undefined; + if (indexInfo) { + if (accessExpression && ts.isAssignmentTarget(accessExpression) && indexInfo.isReadonly) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + return unknownType; + } + return indexInfo.type; + } + if (accessExpression && !isConstEnumObjectType(objectType)) { + if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (getIndexTypeOfType(objectType, 1 /* Number */)) { + error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); + } + else { + error(accessExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(objectType)); + } + } + return anyType; + } + } + if (accessNode) { + var indexNode = accessNode.kind === 177 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { + error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); + } + else if (indexType.flags & (2 /* String */ | 4 /* Number */)) { + error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); + } + else { + error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); + } + } + return unknownType; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + if (indexType.flags & 16384 /* TypeParameter */) { + if (!isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { + if (accessNode) { + error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); + } + return unknownType; + } + return getIndexedAccessTypeForTypeParameter(objectType, indexType); + } + var apparentType = getApparentType(objectType); + if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8190 /* Primitive */)) { + var propTypes = []; + for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { + var t = _a[_i]; + var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, /*cacheSymbol*/ false); + if (propType === unknownType) { + return unknownType; + } + propTypes.push(propType); + } + return getUnionType(propTypes); + } + return getPropertyTypeForIndexType(apparentType, indexType, accessNode, /*cacheSymbol*/ true); + } + function getTypeFromIndexedAccessTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIndexedAccessType(getTypeFromTypeNodeNoAlias(node.objectType), getTypeFromTypeNodeNoAlias(node.indexType), node); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments) { var links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers - var type = createObjectType(16 /* Anonymous */, node.symbol); - type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = aliasTypeArguments; - links.resolvedType = type; + if (ts.isEmpty(node.symbol.members) && !aliasSymbol && !aliasTypeArguments) { + links.resolvedType = emptyTypeLiteralType; + } + else { + var type = createObjectType(16 /* Anonymous */, node.symbol); + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = aliasTypeArguments; + links.resolvedType = type; + } } return links.resolvedType; } + /** + * Since the source of spread types are object literals, which are not binary, + * this function should be called in a left folding style, with left = previous result of getSpreadType + * and right = the new element to be spread. + */ + function getSpreadType(left, right, isFromObjectLiteral) { + ts.Debug.assert(!!(left.flags & (32768 /* Object */ | 1 /* Any */)) && !!(right.flags & (32768 /* Object */ | 1 /* Any */)), "Only object types may be spread."); + if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + return anyType; + } + var members = ts.createMap(); + var skippedPrivateMembers = ts.createMap(); + var stringIndexInfo; + var numberIndexInfo; + if (left === emptyObjectType) { + // for the first spread element, left === emptyObjectType, so take the right's string indexer + stringIndexInfo = getIndexInfoOfType(right, 0 /* String */); + numberIndexInfo = getIndexInfoOfType(right, 1 /* Number */); + } + else { + stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0 /* String */), getIndexInfoOfType(right, 0 /* String */)); + numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1 /* Number */), getIndexInfoOfType(right, 1 /* Number */)); + } + for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { + var rightProp = _a[_i]; + // we approximate own properties as non-methods plus methods that are inside the object literal + var isOwnProperty = !(rightProp.flags & 8192 /* Method */) || isFromObjectLiteral; + var isSetterWithoutGetter = rightProp.flags & 65536 /* SetAccessor */ && !(rightProp.flags & 32768 /* GetAccessor */); + if (getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + skippedPrivateMembers[rightProp.name] = true; + } + else if (isOwnProperty && !isSetterWithoutGetter) { + members[rightProp.name] = rightProp; + } + } + for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { + var leftProp = _c[_b]; + if (leftProp.flags & 65536 /* SetAccessor */ && !(leftProp.flags & 32768 /* GetAccessor */) + || leftProp.name in skippedPrivateMembers) { + continue; + } + if (leftProp.name in members) { + var rightProp = members[leftProp.name]; + var rightType = getTypeOfSymbol(rightProp); + if (maybeTypeOfKind(rightType, 2048 /* Undefined */) || rightProp.flags & 536870912 /* Optional */) { + var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); + var flags = 4 /* Property */ | 67108864 /* Transient */ | (leftProp.flags & 536870912 /* Optional */); + var result = createSymbol(flags, leftProp.name); + result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); + result.leftSpread = leftProp; + result.rightSpread = rightProp; + result.declarations = declarations; + result.isReadonly = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp); + members[leftProp.name] = result; + } + } + else { + members[leftProp.name] = leftProp; + } + } + return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + } function createLiteralType(flags, text) { var type = createType(flags); type.text = text; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 262144 /* FreshLiteral */)) { + if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 1048576 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 262144 /* FreshLiteral */, type.text); + var freshType = createLiteralType(type.flags | 1048576 /* FreshLiteral */, type.text); freshType.regularType = type; type.freshType = freshType; } @@ -28175,7 +29448,7 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 262144 /* FreshLiteral */ ? type.regularType : type; + return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? type.regularType : type; } function getLiteralTypeForText(flags, text) { var map = flags & 32 /* StringLiteral */ ? stringLiteralTypes : numericLiteralTypes; @@ -28207,9 +29480,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 223 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 226 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 149 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 150 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -28229,81 +29502,85 @@ var ts; function getTypeFromTypeNode(node, aliasSymbol, aliasTypeArguments) { switch (node.kind) { case 118 /* AnyKeyword */: - case 258 /* JSDocAllType */: - case 259 /* JSDocUnknownType */: + case 262 /* JSDocAllType */: + case 263 /* JSDocUnknownType */: return anyType; - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: return stringType; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: return numberType; case 121 /* BooleanKeyword */: return booleanType; - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: return esSymbolType; case 104 /* VoidKeyword */: return voidType; - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: return undefinedType; case 94 /* NullKeyword */: return nullType; - case 128 /* NeverKeyword */: + case 129 /* NeverKeyword */: return neverType; - case 283 /* JSDocNullKeyword */: + case 287 /* JSDocNullKeyword */: return nullType; - case 284 /* JSDocUndefinedKeyword */: + case 288 /* JSDocUndefinedKeyword */: return undefinedType; - case 285 /* JSDocNeverKeyword */: + case 289 /* JSDocNeverKeyword */: return neverType; - case 166 /* ThisType */: + case 167 /* ThisType */: case 98 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 167 /* LiteralType */: + case 170 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 282 /* JSDocLiteralType */: + case 286 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 156 /* TypeReference */: - case 267 /* JSDocTypeReference */: + case 157 /* TypeReference */: + case 271 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return booleanType; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 161 /* ArrayType */: - case 260 /* JSDocArrayType */: + case 162 /* ArrayType */: + case 264 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 163 /* UnionType */: - case 261 /* JSDocUnionType */: + case 164 /* UnionType */: + case 265 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node, aliasSymbol, aliasTypeArguments); - case 165 /* ParenthesizedType */: - case 263 /* JSDocNullableType */: - case 264 /* JSDocNonNullableType */: - case 271 /* JSDocConstructorType */: - case 272 /* JSDocThisType */: - case 268 /* JSDocOptionalType */: + case 166 /* ParenthesizedType */: + case 267 /* JSDocNullableType */: + case 268 /* JSDocNonNullableType */: + case 275 /* JSDocConstructorType */: + case 276 /* JSDocThisType */: + case 272 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 265 /* JSDocRecordType */: + case 269 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 160 /* TypeLiteral */: - case 281 /* JSDocTypeLiteral */: - case 269 /* JSDocFunctionType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 161 /* TypeLiteral */: + case 285 /* JSDocTypeLiteral */: + case 273 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); + case 168 /* TypeOperator */: + return getTypeFromTypeOperatorNode(node); + case 169 /* IndexedAccessType */: + return getTypeFromIndexedAccessTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 70 /* Identifier */: - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 262 /* JSDocTupleType */: + case 266 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 270 /* JSDocVariadicType */: + case 274 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -28320,6 +29597,12 @@ var ts; } return items; } + function instantiateTypes(types, mapper) { + return instantiateList(types, mapper, instantiateType); + } + function instantiateSignatures(signatures, mapper) { + return instantiateList(signatures, mapper, instantiateSignature); + } function createUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -28342,7 +29625,6 @@ var ts; count == 2 ? createBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : createArrayTypeMapper(sources, targets); mapper.mappedTypes = sources; - mapper.targetTypes = targets; return mapper; } function createTypeEraser(sources) { @@ -28454,11 +29736,14 @@ var ts; result.target = type; result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = mapper.targetTypes; + result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); mapper.instantiations[type.id] = result; return result; } function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { + if (!(symbol.declarations && symbol.declarations.length)) { + return false; + } var mappedTypes = mapper.mappedTypes; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first @@ -28466,23 +29751,23 @@ var ts; var node = symbol.declarations[0].parent; while (node) { switch (node.kind) { - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28492,15 +29777,15 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 226 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: + case 229 /* ModuleDeclaration */: + case 260 /* SourceFile */: return false; } node = node.parent; @@ -28526,14 +29811,20 @@ var ts; instantiateAnonymousType(type, mapper) : type; } if (type.objectFlags & 4 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } } if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (type.flags & 131072 /* Intersection */) { - return getIntersectionType(instantiateList(type.types, mapper, instantiateType), type.aliasSymbol, mapper.targetTypes); + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + } + if (type.flags & 262144 /* Index */) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288 /* IndexedAccess */) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } } return type; @@ -28544,27 +29835,27 @@ 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 !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return node.operatorToken.kind === 53 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -28579,7 +29870,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 184 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -28856,10 +30147,10 @@ var ts; return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 262144 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { @@ -28872,7 +30163,7 @@ var ts; return related === 1 /* Succeeded */; } } - if (source.flags & 245760 /* StructuredOrTypeParameter */ || target.flags & 245760 /* StructuredOrTypeParameter */) { + if (source.flags & 507904 /* StructuredOrTypeParameter */ || target.flags & 507904 /* StructuredOrTypeParameter */) { return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); } return false; @@ -28919,9 +30210,15 @@ var ts; targetType = typeToString(target, /*enclosingDeclaration*/ undefined, 128 /* UseFullyQualifiedType */); } if (!message) { - message = relation === comparableRelation ? - ts.Diagnostics.Type_0_is_not_comparable_to_type_1 : - ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + if (relation === comparableRelation) { + message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1; + } + else if (sourceType === targetType) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; + } + else { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; + } } reportError(message, sourceType, targetType); } @@ -28941,10 +30238,10 @@ var ts; // Ternary.False if they are not related. function isRelatedTo(source, target, reportErrors, headMessage) { var result; - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 1048576 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 262144 /* FreshLiteral */) { + if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 1048576 /* FreshLiteral */) { target = target.regularType; } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -28955,7 +30252,7 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (getObjectFlags(source) & 64 /* ObjectLiteral */ && source.flags & 262144 /* FreshLiteral */) { + if (getObjectFlags(source) & 64 /* ObjectLiteral */ && source.flags & 1048576 /* FreshLiteral */) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -29013,6 +30310,26 @@ var ts; return result; } } + if (target.flags & 16384 /* TypeParameter */) { + // Given a type parameter K with a constraint keyof T, a type S is + // assignable to K if S is assignable to keyof T. + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144 /* Index */) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + } + } + else if (target.flags & 262144 /* Index */) { + // Given a type parameter T with a constraint C, a type S is assignable to + // keyof T if S is assignable to keyof C. + var constraint = getConstraintOfTypeParameter(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } if (source.flags & 16384 /* TypeParameter */) { var constraint = getConstraintOfTypeParameter(source); if (!constraint || constraint.flags & 1 /* Any */) { @@ -29305,8 +30622,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 64 /* ObjectLiteral */); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var targetProp = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var targetProp = properties_3[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -29799,8 +31116,8 @@ var ts; type; } function getWidenedLiteralType(type) { - return type.flags & 32 /* StringLiteral */ && type.flags & 262144 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 262144 /* FreshLiteral */ ? numberType : + return type.flags & 32 /* StringLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? stringType : + type.flags & 64 /* NumberLiteral */ && type.flags & 1048576 /* FreshLiteral */ ? numberType : type.flags & 128 /* BooleanLiteral */ ? booleanType : type.flags & 256 /* EnumLiteral */ ? type.baseType : type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */) ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : @@ -29895,7 +31212,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(getObjectFlags(type) & 64 /* ObjectLiteral */ && type.flags & 262144 /* FreshLiteral */)) { + if (!(getObjectFlags(type) & 64 /* ObjectLiteral */ && type.flags & 1048576 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -29905,7 +31222,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~262144 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~1048576 /* FreshLiteral */; regularNew.objectFlags |= 64 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; @@ -29923,7 +31240,7 @@ var ts; return type.flags & 6144 /* Nullable */ ? type : getWidenedType(type); } function getWidenedType(type) { - if (type.flags & 1572864 /* RequiresWidening */) { + if (type.flags & 6291456 /* RequiresWidening */) { if (type.flags & 6144 /* Nullable */) { return anyType; } @@ -29972,7 +31289,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 524288 /* ContainsWideningType */) { + if (t.flags & 2097152 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -29986,25 +31303,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 143 /* Parameter */: + case 144 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 170 /* BindingElement */: + case 173 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -30017,7 +31334,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288 /* ContainsWideningType */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -30145,7 +31462,7 @@ var ts; // it as an inference candidate. Hopefully, a better candidate will come along that does // not contain anyFunctionType when we come back to this argument for its second round // of inference. - if (source.flags & 2097152 /* ContainsAnyFunctionType */) { + if (source.flags & 8388608 /* ContainsAnyFunctionType */) { return; } for (var i = 0; i < typeParameters.length; i++) { @@ -30244,8 +31561,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -30323,7 +31640,7 @@ var ts; } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 8190 /* Primitive */); + return constraint && maybeTypeOfKind(constraint, 8190 /* Primitive */ | 262144 /* Index */); } function getInferredType(context, index) { var inferredType = context.inferredTypes[index]; @@ -30393,10 +31710,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return true; case 70 /* Identifier */: - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: node = node.parent; continue; default: @@ -30417,7 +31734,7 @@ var ts; if (node.kind === 98 /* ThisKeyword */) { return "0"; } - if (node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 176 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30428,7 +31745,7 @@ var ts; case 70 /* Identifier */: case 98 /* ThisKeyword */: return node; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; @@ -30437,19 +31754,19 @@ var ts; switch (source.kind) { case 70 /* Identifier */: return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 219 /* VariableDeclaration */ || target.kind === 170 /* BindingElement */) && + (target.kind === 222 /* VariableDeclaration */ || target.kind === 173 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 98 /* ThisKeyword */: return target.kind === 98 /* ThisKeyword */; - case 173 /* PropertyAccessExpression */: - return target.kind === 173 /* PropertyAccessExpression */ && + case 176 /* PropertyAccessExpression */: + return target.kind === 176 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 173 /* PropertyAccessExpression */) { + while (source.kind === 176 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30462,7 +31779,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 173 /* PropertyAccessExpression */ && + return target.kind === 176 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } @@ -30470,7 +31787,7 @@ var ts; if (expr.kind === 70 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 176 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30500,7 +31817,7 @@ var ts; } } } - if (callExpression.expression.kind === 173 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 176 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30616,7 +31933,7 @@ var ts; return type; } function getTypeOfDestructuredProperty(type, name) { - var text = getTextOfPropertyName(name); + var text = ts.getTextOfPropertyName(name); return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || @@ -30627,19 +31944,19 @@ var ts; checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType; } - function getTypeOfDestructuredSpreadElement(type) { + function getTypeOfDestructuredSpreadExpression(type) { return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - return node.parent.kind === 171 /* ArrayLiteralExpression */ || node.parent.kind === 253 /* PropertyAssignment */ ? + return node.parent.kind === 174 /* ArrayLiteralExpression */ || node.parent.kind === 256 /* PropertyAssignment */ ? getTypeWithDefault(getAssignedType(node), node.right) : checkExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); } - function getAssignedTypeOfSpreadElement(node) { - return getTypeOfDestructuredSpreadElement(getAssignedType(node.parent)); + function getAssignedTypeOfSpreadExpression(node) { + return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent)); } function getAssignedTypeOfPropertyAssignment(node) { return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name); @@ -30650,21 +31967,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return stringType; - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return undefinedType; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 192 /* SpreadElementExpression */: - return getAssignedTypeOfSpreadElement(parent); - case 253 /* PropertyAssignment */: + case 195 /* SpreadElement */: + return getAssignedTypeOfSpreadExpression(parent); + case 256 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -30672,11 +31989,11 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 168 /* ObjectBindingPattern */ ? + var type = pattern.kind === 171 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : - getTypeOfDestructuredSpreadElement(parentType); + getTypeOfDestructuredSpreadExpression(parentType); return getTypeWithDefault(type, node.initializer); } function getTypeOfInitializer(node) { @@ -30690,35 +32007,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 208 /* ForInStatement */) { + if (node.parent.parent.kind === 211 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.parent.kind === 212 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 219 /* VariableDeclaration */ ? + return node.kind === 222 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */ ? + return node.kind === 222 /* VariableDeclaration */ || node.kind === 173 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 219 /* VariableDeclaration */ && node.initializer && + return node.kind === 222 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 170 /* BindingElement */ && node.parent.kind === 188 /* BinaryExpression */ && + node.kind !== 173 /* BindingElement */ && node.parent.kind === 191 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: switch (node.operatorToken.kind) { case 57 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -30730,13 +32047,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 179 /* ParenthesizedExpression */ || - parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 188 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 182 /* ParenthesizedExpression */ || + parent.kind === 191 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || + parent.kind === 191 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 252 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -30872,11 +32189,11 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 173 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 175 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 174 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 176 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 178 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 177 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 188 /* BinaryExpression */ && + parent.parent.kind === 191 /* BinaryExpression */ && parent.parent.operatorToken.kind === 57 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -30885,7 +32202,7 @@ var ts; } function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 246783 /* Narrowable */)) { + if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 1033215 /* Narrowable */)) { return declaredType; } var initialType = assumeInitialized ? declaredType : @@ -30899,7 +32216,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 = getObjectFlags(evolvedType) & 128 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 197 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 200 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -30948,7 +32265,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 173 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 176 /* PropertyAccessExpression */) { flow = container.flowNode; continue; } @@ -30974,7 +32291,7 @@ var ts; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - if (node.parent.kind === 186 /* PrefixUnaryExpression */ || node.parent.kind === 187 /* PostfixUnaryExpression */) { + if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -31002,7 +32319,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 175 /* CallExpression */ ? + var expr = node.kind === 178 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -31010,7 +32327,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 128 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 178 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -31165,7 +32482,7 @@ var ts; return cache[key] = result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 173 /* PropertyAccessExpression */ && + return expr.kind === 176 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -31199,10 +32516,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 === 183 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 186 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 183 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 186 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -31400,10 +32717,10 @@ var ts; } } else { - var invokedExpression = skipParenthesizedNodes(callExpression.expression); - if (invokedExpression.kind === 174 /* ElementAccessExpression */ || invokedExpression.kind === 173 /* PropertyAccessExpression */) { + var invokedExpression = ts.skipParentheses(callExpression.expression); + if (invokedExpression.kind === 177 /* ElementAccessExpression */ || invokedExpression.kind === 176 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; - var possibleReference = skipParenthesizedNodes(accessExpression.expression); + var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { return getNarrowedType(type, predicate.type, assumeTrue); } @@ -31420,15 +32737,15 @@ var ts; switch (expr.kind) { case 70 /* Identifier */: case 98 /* ThisKeyword */: - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: if (expr.operator === 50 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -31460,19 +32777,13 @@ var ts; // binder), we simply return the declared type of the symbol. return getTypeOfSymbol(symbol); } - function skipParenthesizedNodes(expression) { - while (expression.kind === 179 /* ParenthesizedExpression */) { - expression = expression.expression; - } - return expression; - } function getControlFlowContainer(node) { while (true) { node = node.parent; if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 227 /* ModuleBlock */ || - node.kind === 256 /* SourceFile */ || - node.kind === 146 /* PropertyDeclaration */) { + node.kind === 230 /* ModuleBlock */ || + node.kind === 260 /* SourceFile */ || + node.kind === 147 /* PropertyDeclaration */) { return node; } } @@ -31504,7 +32815,7 @@ var ts; if (node.kind === 70 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 143 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 144 /* Parameter */) { symbol.isAssigned = true; } } @@ -31518,6 +32829,9 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); + if (symbol === unknownSymbol) { + return unknownType; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that // arguments objects will be bound to the inner object; emitting arrow function natively in ES6, arguments objects @@ -31527,16 +32841,17 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 184 /* 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.hasModifier(container, 256 /* Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 262144 /* AwaitContext */) { + if (node.flags & 524288 /* AwaitContext */) { getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } + return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -31548,7 +32863,7 @@ var ts; // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. if (languageVersion === 2 /* ES2015 */ - && declaration_1.kind === 222 /* ClassDeclaration */ + && declaration_1.kind === 225 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31560,14 +32875,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 193 /* ClassExpression */) { + else if (declaration_1.kind === 196 /* 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 !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 146 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 147 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -31582,23 +32897,34 @@ var ts; checkNestedBlockScopedBinding(node, symbol); var type = getTypeOfSymbol(localOrExportSymbol); var declaration = localOrExportSymbol.valueDeclaration; + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (!(localOrExportSymbol.flags & 3 /* Variable */)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + return unknownType; + } + if (isReadonlySymbol(localOrExportSymbol)) { + error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); + return unknownType; + } + } // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (!(localOrExportSymbol.flags & 3 /* Variable */) || ts.isAssignmentTarget(node) || !declaration) { + if (!(localOrExportSymbol.flags & 3 /* Variable */) || assignmentKind === 1 /* Definite */ || !declaration) { return type; } // 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 === 143 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 144 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // 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 === 180 /* FunctionExpression */ || - flowContainer.kind === 181 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 183 /* FunctionExpression */ || + flowContainer.kind === 184 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -31626,7 +32952,7 @@ var ts; // Return the declared type to reduce follow-on errors return type; } - return flowType; + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { var current = node; @@ -31641,7 +32967,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 252 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 255 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -31666,8 +32992,8 @@ 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 (container.kind === 207 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 220 /* VariableDeclarationList */).parent === container && + if (container.kind === 210 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 223 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -31681,7 +33007,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { var current = node; // skip parenthesized nodes - while (current.parent.kind === 179 /* ParenthesizedExpression */) { + while (current.parent.kind === 182 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -31689,7 +33015,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 186 /* PrefixUnaryExpression */ || current.parent.kind === 187 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 189 /* PrefixUnaryExpression */ || current.parent.kind === 190 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; } @@ -31710,7 +33036,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 146 /* PropertyDeclaration */ || container.kind === 149 /* Constructor */) { + if (container.kind === 147 /* PropertyDeclaration */ || container.kind === 150 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -31758,7 +33084,7 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 149 /* Constructor */) { + if (container.kind === 150 /* Constructor */) { var containingClassDecl = container.parent; var baseTypeNode = ts.getClassExtendsHeritageClauseElement(containingClassDecl); // If a containing class does not have extends clause or the class extends null @@ -31779,32 +33105,32 @@ var ts; } } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 181 /* ArrowFunction */) { + if (container.kind === 184 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* 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 225 /* EnumDeclaration */: + case 228 /* 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 149 /* Constructor */: + case 150 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31816,7 +33142,7 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 180 /* FunctionExpression */ && + if (container.kind === 183 /* FunctionExpression */ && ts.isInJavaScriptFile(container.parent) && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') @@ -31853,28 +33179,28 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 269 /* JSDocFunctionType */) { + if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 273 /* JSDocFunctionType */) { var jsDocFunctionType = typeTag.typeExpression.type; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 272 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 276 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 143 /* Parameter */) { + if (n.kind === 144 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 175 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 178 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 181 /* ArrowFunction */) { + while (container && container.kind === 184 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -31888,16 +33214,16 @@ var ts; // [super.foo()]() {} // } var current = node; - while (current && current !== container && current.kind !== 141 /* ComputedPropertyName */) { + while (current && current !== container && current.kind !== 142 /* ComputedPropertyName */) { current = current.parent; } - if (current && current.kind === 141 /* ComputedPropertyName */) { + if (current && current.kind === 142 /* 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 === 172 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 175 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31968,7 +33294,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 148 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 149 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -31982,7 +33308,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 172 /* ObjectLiteralExpression */) { + if (container.parent.kind === 175 /* 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 unknownType; @@ -32002,7 +33328,7 @@ var ts; } return unknownType; } - if (container.kind === 149 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 150 /* 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 unknownType; @@ -32017,7 +33343,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 === 149 /* Constructor */; + return container.kind === 150 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -32025,21 +33351,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 === 172 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 175 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 148 /* MethodDeclaration */ || - container.kind === 147 /* MethodSignature */ || - container.kind === 150 /* GetAccessor */ || - container.kind === 151 /* SetAccessor */; + return container.kind === 149 /* MethodDeclaration */ || + container.kind === 148 /* MethodSignature */ || + container.kind === 151 /* GetAccessor */ || + container.kind === 152 /* SetAccessor */; } else { - return container.kind === 148 /* MethodDeclaration */ || - container.kind === 147 /* MethodSignature */ || - container.kind === 150 /* GetAccessor */ || - container.kind === 151 /* SetAccessor */ || - container.kind === 146 /* PropertyDeclaration */ || - container.kind === 145 /* PropertySignature */ || - container.kind === 149 /* Constructor */; + return container.kind === 149 /* MethodDeclaration */ || + container.kind === 148 /* MethodSignature */ || + container.kind === 151 /* GetAccessor */ || + container.kind === 152 /* SetAccessor */ || + container.kind === 147 /* PropertyDeclaration */ || + container.kind === 146 /* PropertySignature */ || + container.kind === 150 /* Constructor */; } } } @@ -32047,7 +33373,7 @@ var ts; } } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 181 /* ArrowFunction */) { + if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 184 /* ArrowFunction */) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -32113,7 +33439,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 143 /* Parameter */) { + if (declaration.kind === 144 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -32124,11 +33450,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_15 = declaration.propertyName || declaration.name; + var name_20 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_15)) { - var text = getTextOfPropertyName(name_15); + !ts.isBindingPattern(name_20)) { + var text = ts.getTextOfPropertyName(name_20); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -32165,7 +33491,7 @@ var ts; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 143 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 144 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -32176,8 +33502,8 @@ var ts; // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 149 /* Constructor */ || - functionDecl.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 151 /* SetAccessor */))) { + functionDecl.kind === 150 /* Constructor */ || + functionDecl.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 152 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -32199,7 +33525,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 177 /* TaggedTemplateExpression */) { + if (template.parent.kind === 180 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -32327,13 +33653,13 @@ var ts; var kind = attribute.kind; var jsxElement = attribute.parent; var attrsType = getJsxElementAttributesType(jsxElement); - if (attribute.kind === 246 /* JsxAttribute */) { + if (attribute.kind === 249 /* JsxAttribute */) { if (!attrsType || isTypeAny(attrsType)) { return undefined; } return getTypeOfPropertyOfType(attrsType, attribute.name.text); } - else if (attribute.kind === 247 /* JsxSpreadAttribute */) { + else if (attribute.kind === 250 /* JsxSpreadAttribute */) { return attrsType; } ts.Debug.fail("Expected JsxAttribute or JsxSpreadAttribute, got ts.SyntaxKind[" + kind + "]"); @@ -32371,41 +33697,41 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 219 /* VariableDeclaration */: - case 143 /* Parameter */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 170 /* BindingElement */: + case 222 /* VariableDeclaration */: + case 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 173 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 181 /* ArrowFunction */: - case 212 /* ReturnStatement */: + case 184 /* ArrowFunction */: + case 215 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 198 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 190 /* TemplateExpression */); + case 201 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 193 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return getContextualType(parent); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return getContextualType(parent); - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); } return undefined; @@ -32437,7 +33763,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */; + return node.kind === 183 /* FunctionExpression */ || node.kind === 184 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -32456,7 +33782,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 !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -32512,7 +33838,7 @@ var ts; function isInferentialContext(mapper) { return mapper && mapper.context; } - function checkSpreadElementExpression(node, contextualMapper) { + function checkSpreadExpression(node, contextualMapper) { // It is usually not safe to call checkExpressionCached if we can be contextually typing. // You can tell that we are contextually typing because of the contextualMapper parameter. // While it is true that a spread element can have a contextual type, it does not do anything @@ -32523,8 +33849,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); } function hasDefaultValue(node) { - return (node.kind === 170 /* BindingElement */ && !!node.initializer) || - (node.kind === 188 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 173 /* BindingElement */ && !!node.initializer) || + (node.kind === 191 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); } function checkArrayLiteral(node, contextualMapper) { var elements = node.elements; @@ -32533,7 +33859,7 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 192 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 195 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -32557,7 +33883,7 @@ var ts; var type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 192 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 195 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -32572,7 +33898,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 169 /* ArrayBindingPattern */ || pattern.kind === 171 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 172 /* ArrayBindingPattern */ || pattern.kind === 174 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -32580,7 +33906,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 194 /* OmittedExpression */) { + if (patternElement.kind !== 197 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -32597,7 +33923,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 141 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 142 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -32665,9 +33991,11 @@ var ts; checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); var propertiesArray = []; + var spread = emptyObjectType; + var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 168 /* ObjectBindingPattern */ || contextualType.pattern.kind === 172 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 171 /* ObjectBindingPattern */ || contextualType.pattern.kind === 175 /* ObjectLiteralExpression */); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -32675,18 +34003,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 253 /* PropertyAssignment */ || - memberDecl.kind === 254 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 256 /* PropertyAssignment */ || + memberDecl.kind === 257 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 253 /* PropertyAssignment */) { + if (memberDecl.kind === 256 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 148 /* MethodDeclaration */) { + else if (memberDecl.kind === 149 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 254 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 257 /* ShorthandPropertyAssignment */); type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -32694,8 +34022,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 === 253 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 254 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 256 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 257 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 536870912 /* Optional */; } @@ -32723,13 +34051,30 @@ var ts; prop.target = member; member = prop; } + else if (memberDecl.kind === 258 /* SpreadAssignment */) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + propertiesArray = []; + propertiesTable = ts.createMap(); + hasComputedStringProperty = false; + hasComputedNumberProperty = false; + typeFlags = 0; + } + var type = checkExpression(memberDecl.expression); + if (!(type.flags & (32768 /* Object */ | 1 /* Any */))) { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + return unknownType; + } + spread = getSpreadType(spread, type, /*isFromObjectLiteral*/ false); + continue; + } else { // TypeScript 1.0 spec (April 2014) // A get accessor declaration is processed in the same manner as // 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 === 150 /* GetAccessor */ || memberDecl.kind === 151 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 151 /* GetAccessor */ || memberDecl.kind === 152 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (ts.hasDynamicName(memberDecl)) { @@ -32759,19 +34104,33 @@ var ts; } } } - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; - var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 262144 /* FreshLiteral */; - result.flags |= 1048576 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 3670016 /* PropagatingFlags */); - result.objectFlags |= 64 /* ObjectLiteral */; - if (patternWithComputedProperties) { - result.objectFlags |= 256 /* ObjectLiteralPatternWithComputedProperties */; + if (spread !== emptyObjectType) { + if (propertiesArray.length > 0) { + spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); + } + spread.flags |= propagatedFlags; + spread.symbol = node.symbol; + return spread; } - if (inDestructuringPattern) { - result.pattern = node; + return createObjectLiteralType(); + function createObjectLiteralType() { + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1 /* Number */) : undefined; + var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; + result.flags |= 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); + result.objectFlags |= 64 /* ObjectLiteral */; + if (patternWithComputedProperties) { + result.objectFlags |= 256 /* ObjectLiteralPatternWithComputedProperties */; + } + if (inDestructuringPattern) { + result.pattern = node; + } + if (!(result.flags & 6144 /* Nullable */)) { + propagatedFlags |= (result.flags & 14680064 /* PropagatingFlags */); + } + return result; } - return result; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); @@ -32791,13 +34150,13 @@ var ts; for (var _i = 0, _a = node.children; _i < _a.length; _i++) { var child = _a[_i]; switch (child.kind) { - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: checkJsxExpression(child); break; - case 242 /* JsxElement */: + case 245 /* JsxElement */: checkJsxElement(child); break; - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: checkJsxSelfClosingElement(child); break; } @@ -32816,7 +34175,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 173 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 176 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { return false; } else { @@ -32834,7 +34193,7 @@ var ts; var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - var attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); + var attributeType = getTypeOfPropertyOfType(elementAttributesType, ts.getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, 0 /* String */); if (attributeType) { correspondingPropType = attributeType; } @@ -33148,10 +34507,10 @@ var ts; function checkJsxOpeningLikeElement(node) { checkGrammarJsxElement(node); checkJsxPreconditions(node); - // The reactNamespace symbol should be marked as 'used' so we don't incorrectly elide its import. And if there - // is no reactNamespace symbol in scope when targeting React emit, we should issue an error. + // 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 reactRefErr = compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; - var reactNamespace = compilerOptions.reactNamespace ? compilerOptions.reactNamespace : "React"; + var reactNamespace = getJsxNamespace(); var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked @@ -33169,11 +34528,11 @@ var ts; // thus should have their types ignored var sawSpreadedAny = false; for (var i = node.attributes.length - 1; i >= 0; i--) { - if (node.attributes[i].kind === 246 /* JsxAttribute */) { + if (node.attributes[i].kind === 249 /* JsxAttribute */) { checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); } else { - ts.Debug.assert(node.attributes[i].kind === 247 /* JsxSpreadAttribute */); + ts.Debug.assert(node.attributes[i].kind === 250 /* JsxSpreadAttribute */); var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); if (isTypeAny(spreadType)) { sawSpreadedAny = true; @@ -33203,7 +34562,7 @@ var ts; // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 146 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 147 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedModifierFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 4 /* Public */ | 32 /* Static */ : 0; @@ -33222,7 +34581,7 @@ var ts; function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); var declaringClass = getDeclaredTypeOfSymbol(getParentOfSymbol(prop)); - var errorNode = node.kind === 173 /* PropertyAccessExpression */ || node.kind === 219 /* VariableDeclaration */ ? + var errorNode = node.kind === 176 /* PropertyAccessExpression */ || node.kind === 222 /* VariableDeclaration */ ? node.name : node.right; if (left.kind === 96 /* SuperKeyword */) { @@ -33233,7 +34592,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 148 /* MethodDeclaration */) { + if (languageVersion < 2 /* ES2015 */ && getDeclarationKindFromSymbol(prop) !== 149 /* MethodDeclaration */) { // `prop` refers to a *property* declared in the super class // rather than a *method*, so it does not satisfy the above criteria. error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -33313,6 +34672,33 @@ var ts; function checkQualifiedName(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } + function reportNonexistentProperty(propNode, containingType) { + var errorInfo; + if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { + for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { + var subtype = _a[_i]; + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + function markPropertyAsReferenced(prop) { + if (prop && + noUnusedIdentifiers && + (prop.flags & 106500 /* ClassMember */) && + prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { + if (prop.flags & 16777216 /* Instantiated */) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { var type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -33330,47 +34716,32 @@ var ts; } return unknownType; } - if (noUnusedIdentifiers && - (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && (ts.getModifierFlags(prop.valueDeclaration) & 8 /* Private */)) { - if (prop.flags & 16777216 /* Instantiated */) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } + markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { checkClassPropertyAccess(node, left, apparentType, prop); } var propType = getTypeOfSymbol(prop); + var assignmentKind = ts.getAssignmentTargetKind(node); + if (assignmentKind) { + if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { + error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text); + return unknownType; + } + } // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 173 /* PropertyAccessExpression */ || ts.isAssignmentTarget(node) || + if (node.kind !== 176 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; } - return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); - function reportNonexistentProperty(propNode, containingType) { - var errorInfo; - if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } + var flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 173 /* PropertyAccessExpression */ + var left = node.kind === 176 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -33387,7 +34758,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer.kind === 223 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -33409,14 +34780,14 @@ var ts; * that references a for-in variable for an object with numeric property names. */ function isForInVariableForNumericPropertyNames(expr) { - var e = skipParenthesizedNodes(expr); + var e = ts.skipParentheses(expr); if (e.kind === 70 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 208 /* ForInStatement */ && + if (node.kind === 211 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(checkExpression(node.expression))) { @@ -33430,10 +34801,11 @@ var ts; return false; } function checkIndexedAccess(node) { - // Grammar checking - if (!node.argumentExpression) { + var objectType = checkNonNullExpression(node.expression); + var indexExpression = node.argumentExpression; + if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 176 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 179 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -33443,101 +34815,18 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } + return unknownType; } - // Obtain base constraint such that we can bail out if the constraint is an unknown type - var objectType = getApparentType(checkNonNullExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; + var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); if (objectType === unknownType || objectType === silentNeverType) { return objectType; } - var isConstEnum = isConstEnumObjectType(objectType); - if (isConstEnum && - (!node.argumentExpression || node.argumentExpression.kind !== 9 /* StringLiteral */)) { - error(node.argumentExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); + if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { + error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return unknownType; } - // TypeScript 1.0 spec (April 2014): 4.10 Property Access - // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name - // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. - // - Otherwise, if ObjExpr's apparent type has a numeric index signature and IndexExpr is of type Any, the Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if ObjExpr's apparent type has a string index signature and IndexExpr is of type Any, the String or Number primitive type, or an enum type, - // the property access is of the type of that index signature. - // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. - // See if we can index as a property. - if (node.argumentExpression) { - var name_16 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_16 !== undefined) { - var prop = getPropertyOfType(objectType, name_16); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_16, symbolToString(objectType.symbol)); - return unknownType; - } - } - } - // Check for compatible indexer types. - var allowedNullableFlags = strictNullChecks ? 0 : 6144 /* Nullable */; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 /* StringLike */ | 340 /* NumberLike */ | 512 /* ESSymbol */ | allowedNullableFlags)) { - // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 /* NumberLike */ | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { - var numberIndexInfo = getIndexInfoOfType(objectType, 1 /* Number */); - if (numberIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; - return numberIndexInfo.type; - } - } - // Try to use string indexing. - var stringIndexInfo = getIndexInfoOfType(objectType, 0 /* String */); - if (stringIndexInfo) { - getNodeLinks(node).resolvedIndexInfo = stringIndexInfo; - return stringIndexInfo.type; - } - // Fall back to any. - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) { - error(node, getIndexTypeOfType(objectType, 1 /* Number */) ? - ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number : - ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - // REVIEW: Users should know the type that was actually used. - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_symbol_or_any); - return unknownType; + return getIndexedAccessType(objectType, indexType, node); } - /** - * If indexArgumentExpression is a string literal or number literal, returns its text. - * If indexArgumentExpression is a constant value, returns its string value. - * If indexArgumentExpression is a well known symbol, returns the property name corresponding - * to this symbol, as long as it is a proper symbol reference. - * Otherwise, returns undefined. - */ - function getPropertyNameForIndexedAccess(indexArgumentExpression, indexArgumentType) { - if (indexArgumentExpression.kind === 9 /* StringLiteral */ || indexArgumentExpression.kind === 8 /* NumericLiteral */) { - return indexArgumentExpression.text; - } - if (indexArgumentExpression.kind === 174 /* ElementAccessExpression */ || indexArgumentExpression.kind === 173 /* PropertyAccessExpression */) { - var value = getConstantValue(indexArgumentExpression); - if (value !== undefined) { - return value.toString(); - } - } - if (checkThatExpressionIsProperSymbolReference(indexArgumentExpression, indexArgumentType, /*reportError*/ false)) { - var rightHandSideName = indexArgumentExpression.name.text; - return ts.getPropertyNameForKnownSymbolName(rightHandSideName); - } - return undefined; - } - /** - * A proper symbol reference requires the following: - * 1. The property access denotes a property that exists - * 2. The expression is of the form Symbol. - * 3. The property access is of the primitive type symbol. - * 4. Symbol in this context resolves to the global Symbol object - */ function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { if (expressionType === unknownType) { // There is already an error, so no need to report one. @@ -33574,10 +34863,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 144 /* Decorator */) { + else if (node.kind !== 145 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -33607,13 +34896,13 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_11 = signature.declaration && signature.declaration.parent; + var parent_10 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_11 === lastParent) { + if (lastParent && parent_10 === lastParent) { index++; } else { - lastParent = parent_11; + lastParent = parent_10; index = cutoffIndex; } } @@ -33621,7 +34910,7 @@ var ts; // current declaration belongs to a different symbol // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex index = cutoffIndex = result.length; - lastParent = parent_11; + lastParent = parent_10; } lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless @@ -33643,7 +34932,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 192 /* SpreadElementExpression */) { + if (arg && arg.kind === 195 /* SpreadElement */) { return i; } } @@ -33656,13 +34945,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 190 /* TemplateExpression */) { + if (tagExpression.template.kind === 193 /* 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 templateExpression = tagExpression.template; @@ -33679,7 +34968,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 144 /* Decorator */) { + else if (node.kind === 145 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -33688,7 +34977,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 176 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 179 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -33772,7 +35061,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 197 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -33829,7 +35118,7 @@ var ts; } function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 176 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 179 /* 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. @@ -33846,7 +35135,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 194 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 197 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); @@ -33868,12 +35157,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 175 /* CallExpression */) { + if (node.kind === 178 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 173 /* PropertyAccessExpression */) { + if (callee.kind === 176 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 174 /* ElementAccessExpression */) { + else if (callee.kind === 177 /* ElementAccessExpression */) { return callee.expression; } } @@ -33889,16 +35178,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 177 /* TaggedTemplateExpression */) { + if (node.kind === 180 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 190 /* TemplateExpression */) { + if (template.kind === 193 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 144 /* Decorator */) { + else if (node.kind === 145 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -33923,19 +35212,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* 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. @@ -33945,7 +35234,7 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 143 /* Parameter */: + case 144 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -33969,25 +35258,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -34014,21 +35303,21 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { node = node.parent; - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will @@ -34039,7 +35328,7 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -34065,21 +35354,21 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 222 /* ClassDeclaration */) { + if (node.kind === 225 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 143 /* Parameter */) { + if (node.kind === 144 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 146 /* PropertyDeclaration */) { + if (node.kind === 147 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 148 /* MethodDeclaration */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 149 /* MethodDeclaration */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -34111,10 +35400,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -34126,8 +35415,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 144 /* Decorator */ || - (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */)) { + if (node.kind === 145 /* Decorator */ || + (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -34136,11 +35425,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 144 /* Decorator */) { + if (node.kind === 145 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 177 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 180 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -34149,8 +35438,8 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 177 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 144 /* Decorator */; + var isTaggedTemplate = node.kind === 180 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 145 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; @@ -34221,7 +35510,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 = candidatesOutArray && node.kind === 175 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 178 /* 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 @@ -34569,16 +35858,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 143 /* Parameter */: + case 144 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -34608,13 +35897,13 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 175 /* CallExpression */: + case 178 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 144 /* Decorator */: + case 145 /* Decorator */: return resolveDecorator(node, candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -34663,12 +35952,12 @@ var ts; if (node.expression.kind === 96 /* SuperKeyword */) { return voidType; } - if (node.kind === 176 /* NewExpression */) { + if (node.kind === 179 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 149 /* Constructor */ && - declaration.kind !== 153 /* ConstructSignature */ && - declaration.kind !== 158 /* ConstructorType */ && + declaration.kind !== 150 /* Constructor */ && + declaration.kind !== 154 /* ConstructSignature */ && + declaration.kind !== 159 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -34708,9 +35997,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 221 /* FunctionDeclaration */ + ? 224 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 219 /* VariableDeclaration */ + ? 222 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -34807,8 +36096,8 @@ var ts; links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 168 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 169 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 171 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 172 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); @@ -34866,7 +36155,7 @@ var ts; function createPromiseReturnType(func, promisedType) { var promiseType = createPromiseType(promisedType); if (promiseType === emptyObjectType) { - error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } return promiseType; @@ -34878,7 +36167,7 @@ var ts; } var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 200 /* Block */) { + if (func.body.kind !== 203 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -34968,7 +36257,7 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 214 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 217 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; @@ -35001,7 +36290,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 180 /* FunctionExpression */ || func.kind === 181 /* ArrowFunction */)) { + func.kind === 183 /* FunctionExpression */ || func.kind === 184 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -35030,7 +36319,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 (ts.nodeIsMissing(func.body) || func.body.kind !== 200 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 203 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -35063,10 +36352,10 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 180 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 183 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards @@ -35107,14 +36396,14 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 148 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 149 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 148 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 149 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var isAsync = ts.isAsyncFunctionLike(node); var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); if (!node.asteriskToken) { @@ -35130,7 +36419,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 200 /* Block */) { + if (node.body.kind === 203 /* Block */) { checkSourceElement(node.body); } else { @@ -35177,11 +36466,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) && + (expr.kind === 176 /* PropertyAccessExpression */ || expr.kind === 177 /* ElementAccessExpression */) && expr.expression.kind === 98 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 149 /* Constructor */)) + if (!(func && func.kind === 150 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -35193,50 +36482,25 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 173 /* PropertyAccessExpression */ || expr.kind === 174 /* ElementAccessExpression */) { - var node = skipParenthesizedNodes(expr.expression); + if (expr.kind === 176 /* PropertyAccessExpression */ || expr.kind === 177 /* ElementAccessExpression */) { + var node = ts.skipParentheses(expr.expression); if (node.kind === 70 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 233 /* NamespaceImport */; + return declaration && declaration.kind === 236 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage, constantVariableMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = skipParenthesizedNodes(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 173 /* PropertyAccessExpression */ && node.kind !== 174 /* ElementAccessExpression */) { + var node = ts.skipParentheses(expr); + if (node.kind !== 70 /* Identifier */ && node.kind !== 176 /* PropertyAccessExpression */ && node.kind !== 177 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } - // Because we get the symbol from the resolvedSymbol property, it might be of kind - // SymbolFlags.ExportValue. In this case it is necessary to get the actual export - // symbol, which will have the correct flags set on it. - var links = getNodeLinks(node); - var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (symbol !== unknownSymbol && symbol !== argumentsSymbol) { - // Only variables (and not functions, classes, namespaces, enum objects, or enum members) - // are considered references when referenced using a simple identifier. - if (node.kind === 70 /* Identifier */ && !(symbol.flags & 3 /* Variable */)) { - error(expr, invalidReferenceMessage); - return false; - } - if (isReferenceToReadonlyEntity(node, symbol) || isReferenceThroughNamespaceImport(node)) { - error(expr, constantVariableMessage); - return false; - } - } - } - else if (node.kind === 174 /* ElementAccessExpression */) { - if (links.resolvedIndexInfo && links.resolvedIndexInfo.isReadonly) { - error(expr, constantVariableMessage); - return false; - } - } return true; } function checkDeleteExpression(node) { @@ -35254,7 +36518,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 262144 /* AwaitContext */)) { + if (!(node.flags & 524288 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -35290,7 +36554,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -35304,7 +36568,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, getNonNullableType(operandType), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); } return numberType; } @@ -35395,29 +36659,29 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var p = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var p = properties_5[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { - if (property.kind === 253 /* PropertyAssignment */ || property.kind === 254 /* ShorthandPropertyAssignment */) { - var name_17 = property.name; - if (name_17.kind === 141 /* ComputedPropertyName */) { - checkComputedPropertyName(name_17); + if (property.kind === 256 /* PropertyAssignment */ || property.kind === 257 /* ShorthandPropertyAssignment */) { + var name_21 = property.name; + if (name_21.kind === 142 /* ComputedPropertyName */) { + checkComputedPropertyName(name_21); } - if (isComputedNonLiteralName(name_17)) { + if (isComputedNonLiteralName(name_21)) { return undefined; } - var text = getTextOfPropertyName(name_17); + var text = ts.getTextOfPropertyName(name_21); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 254 /* ShorthandPropertyAssignment */) { + if (property.kind === 257 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -35426,10 +36690,10 @@ var ts; } } else { - error(name_17, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_17)); + error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_21)); } } - else { + else if (property.kind !== 258 /* SpreadAssignment */) { error(property, ts.Diagnostics.Property_assignment_expected); } } @@ -35447,8 +36711,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 194 /* OmittedExpression */) { - if (element.kind !== 192 /* SpreadElementExpression */) { + if (element.kind !== 197 /* OmittedExpression */) { + if (element.kind !== 195 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -35472,11 +36736,11 @@ var ts; } else { if (elementIndex < elements.length - 1) { - error(element, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { var restExpression = element.expression; - if (restExpression.kind === 188 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 191 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -35489,7 +36753,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { var target; - if (exprOrAssignment.kind === 254 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 257 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -35505,21 +36769,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 188 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { + if (target.kind === 191 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 175 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 171 /* ArrayLiteralExpression */) { + if (target.kind === 174 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property)) { + if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(sourceType, targetType, target, /*headMessage*/ undefined); } return sourceType; @@ -35538,35 +36802,35 @@ var ts; case 70 /* Identifier */: case 9 /* StringLiteral */: case 11 /* RegularExpressionLiteral */: - case 177 /* TaggedTemplateExpression */: - case 190 /* TemplateExpression */: + case 180 /* TaggedTemplateExpression */: + case 193 /* TemplateExpression */: case 12 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: case 94 /* NullKeyword */: - case 136 /* UndefinedKeyword */: - case 180 /* FunctionExpression */: - case 193 /* ClassExpression */: - case 181 /* ArrowFunction */: - case 171 /* ArrayLiteralExpression */: - case 172 /* ObjectLiteralExpression */: - case 183 /* TypeOfExpression */: - case 197 /* NonNullExpression */: - case 243 /* JsxSelfClosingElement */: - case 242 /* JsxElement */: + case 137 /* UndefinedKeyword */: + case 183 /* FunctionExpression */: + case 196 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 174 /* ArrayLiteralExpression */: + case 175 /* ObjectLiteralExpression */: + case 186 /* TypeOfExpression */: + case 200 /* NonNullExpression */: + case 246 /* JsxSelfClosingElement */: + case 245 /* JsxElement */: return true; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -35578,9 +36842,9 @@ var ts; } return false; // Some forms listed here for clarity - case 184 /* VoidExpression */: // Explicit opt-out - case 178 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 196 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 187 /* VoidExpression */: // Explicit opt-out + case 181 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 199 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -35600,7 +36864,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 172 /* ObjectLiteralExpression */ || left.kind === 171 /* ArrayLiteralExpression */)) { + if (operator === 57 /* EqualsToken */ && (left.kind === 175 /* ObjectLiteralExpression */ || left.kind === 174 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); } var leftType = checkExpression(left, contextualMapper); @@ -35783,9 +37047,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non - compound operation to be assignable to the type of VarExpr. - var ok = checkReferenceExpression(left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property); - // Use default messages - if (ok) { + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableTo(valueType, leftType, left, /*headMessage*/ undefined); } @@ -35813,7 +37075,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 65536 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 131072 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -35901,8 +37163,8 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = skipParenthesizedNodes(node); - return node.kind === 178 /* TypeAssertionExpression */ || node.kind === 196 /* AsExpression */; + node = ts.skipParentheses(node); + return node.kind === 181 /* TypeAssertionExpression */ || node.kind === 199 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); @@ -35934,7 +37196,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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, contextualMapper); @@ -35945,7 +37207,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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -35975,7 +37237,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 140 /* QualifiedName */) { + if (node.kind === 141 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -35987,9 +37249,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); 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); } @@ -36011,66 +37273,66 @@ var ts; case 100 /* TrueKeyword */: case 85 /* FalseKeyword */: return checkLiteralExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* NoSubstitutionTemplateLiteral */: return stringType; case 11 /* RegularExpressionLiteral */: return globalRegExpType; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: return checkCallExpression(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return checkClassExpression(node); - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: return checkAssertion(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return checkNonNullAssertion(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return checkDeleteExpression(node); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return checkVoidExpression(node); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return checkAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 192 /* SpreadElementExpression */: - return checkSpreadElementExpression(node, contextualMapper); - case 194 /* OmittedExpression */: + case 195 /* SpreadElement */: + return checkSpreadExpression(node, contextualMapper); + case 197 /* OmittedExpression */: return undefinedWideningType; - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return checkYieldExpression(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return checkJsxExpression(node); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return checkJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -36098,7 +37360,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 149 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 150 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -36109,7 +37371,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 149 /* Constructor */ || func.kind === 153 /* ConstructSignature */ || func.kind === 158 /* ConstructorType */) { + if (func.kind === 150 /* Constructor */ || func.kind === 154 /* ConstructSignature */ || func.kind === 159 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -36123,9 +37385,9 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 148 /* MethodDeclaration */ || - node.kind === 221 /* FunctionDeclaration */ || - node.kind === 180 /* FunctionExpression */; + return node.kind === 149 /* MethodDeclaration */ || + node.kind === 224 /* FunctionDeclaration */ || + node.kind === 183 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { @@ -36168,9 +37430,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_18 = _a[_i].name; - if (ts.isBindingPattern(name_18) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_18, parameterName, typePredicate.parameterName)) { + var name_22 = _a[_i].name; + if (ts.isBindingPattern(name_22) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_22, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -36183,16 +37445,16 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 181 /* ArrowFunction */: - case 152 /* CallSignature */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 157 /* FunctionType */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - var parent_12 = node.parent; - if (node === parent_12.type) { - return parent_12; + case 184 /* ArrowFunction */: + case 153 /* CallSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 158 /* FunctionType */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + var parent_11 = node.parent; + if (node === parent_11.type) { + return parent_11; } } } @@ -36202,15 +37464,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_19 = element.name; - if (name_19.kind === 70 /* Identifier */ && - name_19.text === predicateVariableName) { + var name_23 = element.name; + if (name_23.kind === 70 /* Identifier */ && + name_23.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_19.kind === 169 /* ArrayBindingPattern */ || - name_19.kind === 168 /* ObjectBindingPattern */) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_19, predicateVariableNode, predicateVariableName)) { + else if (name_23.kind === 172 /* ArrayBindingPattern */ || + name_23.kind === 171 /* ObjectBindingPattern */) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, predicateVariableNode, predicateVariableName)) { return true; } } @@ -36218,12 +37480,12 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 157 /* FunctionType */ || node.kind === 221 /* FunctionDeclaration */ || node.kind === 158 /* ConstructorType */ || - node.kind === 152 /* CallSignature */ || node.kind === 149 /* Constructor */ || - node.kind === 153 /* ConstructSignature */) { + else if (node.kind === 158 /* FunctionType */ || node.kind === 224 /* FunctionDeclaration */ || node.kind === 159 /* ConstructorType */ || + node.kind === 153 /* CallSignature */ || node.kind === 150 /* Constructor */ || + node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); @@ -36235,10 +37497,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 152 /* CallSignature */: + case 153 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -36281,7 +37543,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* Constructor */) { + if (member.kind === 150 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -36295,13 +37557,13 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; } @@ -36327,7 +37589,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 145 /* PropertySignature */) { + if (member.kind == 146 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: @@ -36349,7 +37611,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 223 /* InterfaceDeclaration */) { + if (node.kind === 226 /* 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 @@ -36369,7 +37631,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -36377,7 +37639,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -36445,12 +37707,12 @@ var ts; if (n.kind === 98 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 180 /* FunctionExpression */ && n.kind !== 221 /* FunctionDeclaration */) { + else if (n.kind !== 183 /* FunctionExpression */ && n.kind !== 224 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 146 /* PropertyDeclaration */ && + return n.kind === 147 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -36480,7 +37742,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -36504,7 +37766,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 150 /* GetAccessor */) { + if (node.kind === 151 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -36514,13 +37776,13 @@ 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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(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 === 150 /* GetAccessor */ ? 151 /* SetAccessor */ : 150 /* GetAccessor */; + var otherKind = node.kind === 151 /* GetAccessor */ ? 152 /* SetAccessor */ : 151 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -36536,11 +37798,11 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 150 /* GetAccessor */) { + if (node.kind === 151 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 172 /* ObjectLiteralExpression */) { + if (node.parent.kind !== 175 /* ObjectLiteralExpression */) { checkSourceElement(node.body); registerForUnusedIdentifiersCheck(node); } @@ -36623,6 +37885,9 @@ var ts; function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } + function checkIndexedAccessType(node) { + getTypeFromIndexedAccessTypeNode(node); + } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8 /* Private */) && ts.isInAmbientContext(node); } @@ -36630,9 +37895,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 !== 223 /* InterfaceDeclaration */ && - n.parent.kind !== 222 /* ClassDeclaration */ && - n.parent.kind !== 193 /* ClassExpression */ && + if (n.parent.kind !== 226 /* InterfaceDeclaration */ && + n.parent.kind !== 225 /* ClassDeclaration */ && + n.parent.kind !== 196 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -36720,7 +37985,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */) && + var reportError = (node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -36759,7 +38024,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 223 /* InterfaceDeclaration */ || node.parent.kind === 160 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 226 /* InterfaceDeclaration */ || node.parent.kind === 161 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -36770,7 +38035,7 @@ 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 === 221 /* FunctionDeclaration */ || node.kind === 148 /* MethodDeclaration */ || node.kind === 147 /* MethodSignature */ || node.kind === 149 /* Constructor */) { + if (node.kind === 224 /* FunctionDeclaration */ || node.kind === 149 /* MethodDeclaration */ || node.kind === 148 /* MethodSignature */ || node.kind === 150 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -36892,16 +38157,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: var result_2 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); @@ -37065,56 +38330,19 @@ var ts; } } /** - * Checks that the return type provided is an instantiation of the global Promise type - * and returns the awaited type of the return type. + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. * - * @param returnType The return type of a FunctionLikeDeclaration - * @param location The node on which to report the error. + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + * + * @param node The signature to check */ - function checkCorrectPromiseType(returnType, location, diagnostic, typeName) { - if (returnType === unknownType) { - // The return type already had some other error, so we ignore and return - // the unknown type. - return unknownType; - } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType === emptyGenericType - || globalPromiseType === getTargetType(returnType)) { - // Either we couldn't resolve the global promise type, which would have already - // reported an error, or we could resolve it and the return type is a valid type - // reference to the global type. In either case, we return the awaited type for - // the return type. - return checkAwaitedType(returnType, location, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); - } - // The promise type was not a valid type reference to the global promise type, so we - // report an error and return the unknown type. - error(location, diagnostic, typeName); - return unknownType; - } - /** - * Checks the return type of an async function to ensure it is a compatible - * Promise implementation. - * @param node The signature to check - * @param returnType The return type for the function - * @remarks - * This checks that an async function has a valid Promise-compatible return type, - * and returns the *awaited type* of the promise. An async function has a valid - * Promise-compatible return type if the resolved value of the return type has a - * construct signature that takes in an `initializer` function that in turn supplies - * a `resolve` function as one of its arguments and results in an object with a - * callable `then` signature. - */ function checkAsyncFunctionReturnType(node) { - if (languageVersion >= 2 /* ES2015 */) { - var returnType = getTypeFromTypeNode(node.type); - return checkCorrectPromiseType(returnType, node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); - if (globalPromiseConstructorLikeType === emptyObjectType) { - // If we couldn't resolve the global PromiseConstructorLike type we cannot verify - // compatibility with __awaiter. - return unknownType; - } // As part of our emit for an async function, we will need to emit the entity name of // the return type annotation as an expression. To meet the necessary runtime semantics // for __awaiter, we must also check that the type of the declaration (e.g. the static @@ -37139,39 +38367,56 @@ var ts; // then(...): Promise; // } // - // When we get the type of the `Promise` symbol here, we get the type of the static - // side of the `Promise` class, which would be `{ new (...): Promise }`. - var promiseType = getTypeFromTypeNode(node.type); - if (promiseType === unknownType && compilerOptions.isolatedModules) { - // If we are compiling with isolatedModules, we may not be able to resolve the - // type as a value. As such, we will just return unknownType; - return unknownType; + var returnType = getTypeFromTypeNode(node.type); + if (languageVersion >= 2 /* ES2015 */) { + if (returnType === unknownType) { + return unknownType; + } + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + // The promise type was not a valid type reference to the global promise type, so we + // report an error and return the unknown type. + error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + return unknownType; + } } - var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; - if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - // try to fall back to global promise type. - var typeName = promiseConstructor - ? symbolToString(promiseConstructor) - : typeToString(promiseType); - return checkCorrectPromiseType(promiseType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); - } - // If the Promise constructor, resolved locally, is an alias symbol we should mark it as referenced. - checkReturnTypeAnnotationAsExpression(node); - // Validate the promise constructor type. - var promiseConstructorType = getTypeOfSymbol(promiseConstructor); - if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { - return unknownType; - } - // Verify there is no local declaration that could collide with the promise constructor. - var promiseName = ts.getEntityNameFromTypeNode(node.type); - var promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName); - var rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, 107455 /* Value */); - if (rootSymbol) { - error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, promiseNameOrNamespaceRoot.text, getFullyQualifiedName(promiseConstructor)); - return unknownType; + else { + // Always mark the type node as referenced if it points to a value + markTypeNodeAsReferenced(node.type); + if (returnType === unknownType) { + return unknownType; + } + var promiseConstructorName = ts.getEntityNameFromTypeNode(node.type); + if (promiseConstructorName === undefined) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); + return unknownType; + } + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; + if (promiseConstructorType === unknownType) { + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var collidingSymbol = getSymbol(node.locals, rootName.text, 107455 /* Value */); + if (collidingSymbol) { + error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, rootName.text, ts.entityNameToString(promiseConstructorName)); + return unknownType; + } } // Get and return the awaited type of the return type. - return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); } /** Check a decorator */ function checkDecorator(node) { @@ -37184,22 +38429,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 143 /* Parameter */: + case 144 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -37207,42 +38452,19 @@ var ts; } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } - /** Checks a type reference node as an expression. */ - function checkTypeNodeAsExpression(node) { - // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we - // serialize the type metadata. - if (node && node.kind === 156 /* TypeReference */) { - var root = getFirstIdentifier(node.typeName); - var meaning = root.parent.kind === 156 /* TypeReference */ ? 793064 /* Type */ : 1920 /* Namespace */; - // Resolve type so we know which symbol is referenced - var rootSymbol = resolveName(root, root.text, meaning | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); - // Resolved symbol is alias - if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */) { - var aliasTarget = resolveAlias(rootSymbol); - // If alias has value symbol - mark alias as referenced - if (aliasTarget.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { - markAliasSymbolAsReferenced(rootSymbol); - } - } - } - } /** - * Checks the type annotation of an accessor declaration or property declaration as - * an expression if it is a type reference to a type with a value declaration. - */ - function checkTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - function checkReturnTypeAnnotationAsExpression(node) { - checkTypeNodeAsExpression(node.type); - } - /** Checks the type annotation of the parameters of a function/method or the constructor of a class as expressions */ - function checkParameterTypeAnnotationsAsExpressions(node) { - // ensure all type annotations with a value declaration are checked as an expression - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - checkTypeAnnotationAsExpression(parameter); + * If a TypeNode can be resolved to a value symbol imported from an external module, it is + * marked as referenced to prevent import elision. + */ + function markTypeNodeAsReferenced(node) { + var typeName = node && ts.getEntityNameFromTypeNode(node); + var rootName = typeName && getFirstIdentifier(typeName); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (rootSymbol + && rootSymbol.flags & 8388608 /* Alias */ + && symbolIsValue(rootSymbol) + && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } /** Check the decorators of a node */ @@ -37261,21 +38483,27 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { - checkParameterTypeAnnotationsAsExpressions(constructor); + for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + markTypeNodeAsReferenced(parameter.type); + } } break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - checkParameterTypeAnnotationsAsExpressions(node); - checkReturnTypeAnnotationAsExpression(node); + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { + var parameter = _c[_b]; + markTypeNodeAsReferenced(parameter.type); + } + markTypeNodeAsReferenced(node.type); break; - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: - checkTypeAnnotationAsExpression(node); + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: + markTypeNodeAsReferenced(node.type); break; } } @@ -37297,7 +38525,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 === 141 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 142 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -37357,43 +38585,43 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 256 /* SourceFile */: - case 226 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 229 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 200 /* Block */: - case 228 /* CaseBlock */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: checkUnusedTypeParameters(node); break; } @@ -37402,11 +38630,11 @@ var ts; } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 223 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { - var _loop_2 = function (key) { + if (node.parent.kind !== 226 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + var _loop_3 = function (key) { var local = node.locals[key]; if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 143 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 144 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -37421,16 +38649,16 @@ var ts; } }; for (var key in node.locals) { - _loop_2(key); + _loop_3(key); } } } function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 219 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 208 /* ForInStatement */ || - declaration.parent.parent.kind === 209 /* ForOfStatement */)) { + if (declaration.kind === 222 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 211 /* ForInStatement */ || + declaration.parent.parent.kind === 212 /* ForOfStatement */)) { return; } } @@ -37447,12 +38675,12 @@ var ts; if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 148 /* MethodDeclaration */ || member.kind === 146 /* PropertyDeclaration */) { + if (member.kind === 149 /* MethodDeclaration */ || member.kind === 147 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 149 /* Constructor */) { + else if (member.kind === 150 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -37500,7 +38728,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 200 /* Block */) { + if (node.kind === 203 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -37523,12 +38751,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 146 /* PropertyDeclaration */ || - node.kind === 145 /* PropertySignature */ || - node.kind === 148 /* MethodDeclaration */ || - node.kind === 147 /* MethodSignature */ || - node.kind === 150 /* GetAccessor */ || - node.kind === 151 /* SetAccessor */) { + if (node.kind === 147 /* PropertyDeclaration */ || + node.kind === 146 /* PropertySignature */ || + node.kind === 149 /* MethodDeclaration */ || + node.kind === 148 /* MethodSignature */ || + node.kind === 151 /* GetAccessor */ || + node.kind === 152 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -37537,7 +38765,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 143 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 144 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -37594,12 +38822,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // 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 === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -37609,12 +38837,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 226 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // 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 === 256 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { + if (parent.kind === 260 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -37649,7 +38877,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 === 219 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 222 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -37659,24 +38887,24 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 220 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 201 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 223 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 204 /* 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 === 200 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 227 /* ModuleBlock */ || - container.kind === 226 /* ModuleDeclaration */ || - container.kind === 256 /* SourceFile */); + (container.kind === 203 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 230 /* ModuleBlock */ || + container.kind === 229 /* ModuleDeclaration */ || + container.kind === 260 /* 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 // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_20 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_20, name_20); + var name_24 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_24, name_24); } } } @@ -37684,7 +38912,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 143 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 144 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -37695,7 +38923,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 173 /* PropertyAccessExpression */) { + if (n.kind === 176 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -37714,7 +38942,7 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 143 /* Parameter */) { + if (symbol.valueDeclaration.kind === 144 /* Parameter */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -37728,7 +38956,7 @@ var ts; } // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - if (current.parent.kind === 146 /* PropertyDeclaration */ && + if (current.parent.kind === 147 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)) { return; @@ -37755,24 +38983,25 @@ 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 === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 170 /* BindingElement */) { + if (node.kind === 173 /* BindingElement */) { // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 141 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access - var parent_13 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_13); - var name_21 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, getTextOfPropertyName(name_21)); - if (parent_13.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_13, parent_13.initializer, parentType, property); + var parent_12 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_12); + var name_25 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_25)); + markPropertyAsReferenced(property); + if (parent_12.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_12, parent_12.initializer, parentType, property); } } // For a binding pattern, check contained binding elements @@ -37780,14 +39009,14 @@ var ts; 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 === 143 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 144 /* Parameter */ && 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)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 211 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37798,7 +39027,7 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 208 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 211 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -37818,10 +39047,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */) { + if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 219 /* VariableDeclaration */ || node.kind === 170 /* BindingElement */) { + if (node.kind === 222 /* VariableDeclaration */ || node.kind === 173 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -37831,8 +39060,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 143 /* Parameter */ && right.kind === 219 /* VariableDeclaration */) || - (left.kind === 219 /* VariableDeclaration */ && right.kind === 143 /* Parameter */)) { + if ((left.kind === 144 /* Parameter */ && right.kind === 222 /* VariableDeclaration */) || + (left.kind === 222 /* VariableDeclaration */ && right.kind === 144 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -37862,7 +39091,7 @@ var ts; } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.modifiers && node.parent.kind === 175 /* ObjectLiteralExpression */) { if (ts.isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -37883,7 +39112,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 202 /* EmptyStatement */) { + if (node.thenStatement.kind === 205 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -37903,12 +39132,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 223 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -37931,14 +39160,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 === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { + if (varExpr.kind === 174 /* ArrayLiteralExpression */ || varExpr.kind === 175 /* 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. @@ -37946,8 +39175,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, /*invalidReferenceMessage*/ ts.Diagnostics.Invalid_left_hand_side_in_for_of_statement, - /*constantVariableMessage*/ ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -37970,7 +39198,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 === 220 /* VariableDeclarationList */) { + if (node.initializer.kind === 223 /* 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); @@ -37984,7 +39212,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 === 171 /* ArrayLiteralExpression */ || varExpr.kind === 172 /* ObjectLiteralExpression */) { + if (varExpr.kind === 174 /* ArrayLiteralExpression */ || varExpr.kind === 175 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 /* StringLike */)) { @@ -37992,7 +39220,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } var rightType = checkNonNullExpression(node.expression); @@ -38234,7 +39462,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 150 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 151 /* SetAccessor */))); + return !!(node.kind === 151 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 152 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; @@ -38261,12 +39489,12 @@ var ts; // for generators. return; } - if (func.kind === 151 /* SetAccessor */) { + if (func.kind === 152 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 149 /* Constructor */) { + else if (func.kind === 150 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -38287,7 +39515,7 @@ var ts; } } } - else if (func.kind !== 149 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 150 /* 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); } @@ -38296,7 +39524,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 262144 /* AwaitContext */) { + if (node.flags & 524288 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -38314,9 +39542,10 @@ var ts; var firstDefaultClause; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); + 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 === 250 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 253 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -38328,15 +39557,21 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 249 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 252 /* CaseClause */) { var caseClause = clause; // 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. var caseType = checkExpression(caseClause.expression); - if (!isTypeEqualityComparableTo(expressionType, caseType)) { + var caseIsLiteral = isLiteralType(caseType); + var comparedExpressionType = expressionType; + if (!caseIsLiteral || !expressionIsLiteral) { + caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType; + comparedExpressionType = getBaseTypeOfLiteralType(expressionType); + } + if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) { // expressionType is not comparable to caseType, try the reversed check and report errors if it fails - checkTypeComparableTo(caseType, expressionType, caseClause.expression, /*headMessage*/ undefined); + checkTypeComparableTo(caseType, comparedExpressionType, caseClause.expression, /*headMessage*/ undefined); } } ts.forEach(clause.statements, checkSourceElement); @@ -38353,7 +39588,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 215 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 218 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -38456,7 +39691,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 141 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 142 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -38514,7 +39749,7 @@ var ts; var firstDecl; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 222 /* ClassDeclaration */ || declaration.kind === 223 /* InterfaceDeclaration */) { + if (declaration.kind === 225 /* ClassDeclaration */ || declaration.kind === 226 /* InterfaceDeclaration */) { if (!firstDecl) { firstDecl = declaration; } @@ -38579,7 +39814,7 @@ var ts; checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); if (baseType_1.symbol.valueDeclaration && !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 222 /* ClassDeclaration */) { + baseType_1.symbol.valueDeclaration.kind === 225 /* ClassDeclaration */) { if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); } @@ -38680,7 +39915,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 193 /* ClassExpression */) { + if (derivedClassDecl.kind === 196 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -38728,7 +39963,7 @@ var ts; } } function isAccessor(kind) { - return kind === 150 /* GetAccessor */ || kind === 151 /* SetAccessor */; + return kind === 151 /* GetAccessor */ || kind === 152 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -38769,8 +40004,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { - var prop = properties_5[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen[prop.name]; if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; @@ -38800,7 +40035,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 223 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 226 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -38848,7 +40083,7 @@ var ts; error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { - var text = getTextOfPropertyName(member.name); + var text = ts.getTextOfPropertyName(member.name); if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } @@ -38907,7 +40142,7 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; @@ -38918,7 +40153,7 @@ var ts; case 51 /* TildeToken */: return ~value_1; } return undefined; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -38943,11 +40178,11 @@ var ts; return undefined; case 8 /* NumericLiteral */: return +e.text; - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return evalConstant(e.expression); case 70 /* Identifier */: - case 174 /* ElementAccessExpression */: - case 173 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: + case 176 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; @@ -38960,7 +40195,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 174 /* ElementAccessExpression */) { + if (e.kind === 177 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -38978,7 +40213,7 @@ var ts; if (current.kind === 70 /* Identifier */) { break; } - else if (current.kind === 173 /* PropertyAccessExpression */) { + else if (current.kind === 176 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -39050,7 +40285,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 !== 225 /* EnumDeclaration */) { + if (declaration.kind !== 228 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -39073,8 +40308,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var declaration = declarations_5[_i]; - if ((declaration.kind === 222 /* ClassDeclaration */ || - (declaration.kind === 221 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 225 /* ClassDeclaration */ || + (declaration.kind === 224 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -39138,7 +40373,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, 222 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 225 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -39189,26 +40424,26 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 201 /* VariableStatement */: + case 204 /* 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 236 /* ExportAssignment */: - case 237 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 240 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 234 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: - var name_22 = node.name; - if (ts.isBindingPattern(name_22)) { - for (var _b = 0, _c = name_22.elements; _b < _c.length; _b++) { + case 173 /* BindingElement */: + case 222 /* VariableDeclaration */: + var name_26 = node.name; + if (ts.isBindingPattern(name_26)) { + for (var _b = 0, _c = name_26.elements; _b < _c.length; _b++) { var el = _c[_b]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); @@ -39216,12 +40451,12 @@ var ts; break; } // fallthrough - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 221 /* FunctionDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 224 /* FunctionDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 227 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -39244,12 +40479,12 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return node; - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: do { node = node.left; } while (node.kind !== 70 /* Identifier */); return node; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 70 /* Identifier */); @@ -39262,9 +40497,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 237 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 230 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 240 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -39297,7 +40532,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 239 /* ExportSpecifier */ ? + var message = node.kind === 242 /* 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)); @@ -39325,7 +40560,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 236 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -39382,8 +40617,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 227 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 256 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 230 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 260 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -39397,7 +40632,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 256 /* SourceFile */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 226 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 260 /* SourceFile */ || node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 229 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -39423,8 +40658,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 === 256 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 226 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 260 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 229 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } @@ -39499,7 +40734,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 221 /* FunctionDeclaration */ && declaration.kind !== 148 /* MethodDeclaration */) || + return (declaration.kind !== 224 /* FunctionDeclaration */ && declaration.kind !== 149 /* MethodDeclaration */) || !!declaration.body; } } @@ -39512,118 +40747,121 @@ 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 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return checkTypeParameter(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return checkParameter(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return checkPropertyDeclaration(node); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return checkSignatureDeclaration(node); - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return checkMethodDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return checkConstructorDeclaration(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return checkAccessorDeclaration(node); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return checkTypeReferenceNode(node); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return checkTypePredicate(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return checkTypeQuery(node); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return checkTypeLiteral(node); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return checkArrayType(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return checkTupleType(node); - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: + case 168 /* TypeOperator */: return checkSourceElement(node.type); - case 221 /* FunctionDeclaration */: + case 169 /* IndexedAccessType */: + return checkIndexedAccessType(node); + case 224 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 200 /* Block */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return checkBlock(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return checkVariableStatement(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return checkExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return checkIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return checkDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return checkWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return checkForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return checkForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return checkForOfStatement(node); - case 210 /* ContinueStatement */: - case 211 /* BreakStatement */: + case 213 /* ContinueStatement */: + case 214 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return checkReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return checkWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return checkSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return checkLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return checkThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return checkTryStatement(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return checkBindingElement(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return checkClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return checkImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return checkExportDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return checkExportAssignment(node); - case 202 /* EmptyStatement */: + case 205 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -39645,17 +40883,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: checkAccessorDeferred(node); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -39717,9 +40955,29 @@ var ts; function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { + // Some global diagnostics are deferred until they are needed and + // may not be reported in the firt call to getGlobalDiagnostics. + // We should catch these changes and report them. + var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; checkSourceFile(sourceFile); - return diagnostics.getDiagnostics(sourceFile.fileName); + var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); + if (currentGlobalDiagnostics !== previousGlobalDiagnostics) { + // If the arrays are not the same reference, new diagnostics were added. + var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics); + return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics); + } + else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) { + // If the arrays are the same reference, but the length has changed, a single + // new diagnostic was added as DiagnosticCollection attempts to reuse the + // same array. + return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics); + } + return semanticDiagnostics; } + // Global diagnostics are always added when a file is not provided to + // getDiagnostics ts.forEach(host.getSourceFiles(), checkSourceFile); return diagnostics.getDiagnostics(); } @@ -39736,7 +40994,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 213 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 216 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -39759,25 +41017,25 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } // fall through; 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 - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* 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. @@ -39786,7 +41044,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -39835,28 +41093,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 142 /* TypeParameter */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: + case 143 /* TypeParameter */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 140 /* QualifiedName */) { + while (node.parent && node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 156 /* TypeReference */ || node.parent.kind === 267 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 157 /* TypeReference */ || node.parent.kind === 271 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 173 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 176 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 195 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 198 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -39873,13 +41131,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 140 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 141 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 230 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 233 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 239 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -39891,7 +41149,7 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 173 /* PropertyAccessExpression */) { + if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 176 /* PropertyAccessExpression */) { var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { case 1 /* ExportsProperty */: @@ -39903,13 +41161,13 @@ var ts; default: } } - if (entityName.parent.kind === 236 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 239 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 173 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 176 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 230 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 233 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -39919,7 +41177,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 195 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 198 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -39943,14 +41201,14 @@ var ts; } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 173 /* PropertyAccessExpression */) { + else if (entityName.kind === 176 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 140 /* QualifiedName */) { + else if (entityName.kind === 141 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -39959,20 +41217,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 156 /* TypeReference */ || entityName.parent.kind === 267 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 157 /* TypeReference */ || entityName.parent.kind === 271 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 246 /* JsxAttribute */) { + else if (entityName.parent.kind === 249 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 155 /* TypePredicate */) { + if (entityName.parent.kind === 156 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -39990,8 +41248,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 170 /* BindingElement */ && - node.parent.parent.kind === 168 /* ObjectBindingPattern */ && + else if (node.parent.kind === 173 /* BindingElement */ && + node.parent.parent.kind === 171 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -40002,8 +41260,8 @@ var ts; } switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 98 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -40017,12 +41275,12 @@ var ts; case 96 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 166 /* ThisType */: + case 167 /* ThisType */: return getTypeFromTypeNode(node).symbol; case 122 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 149 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 150 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -40030,7 +41288,7 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 231 /* ImportDeclaration */ || node.parent.kind === 237 /* ExportDeclaration */) && + ((node.parent.kind === 234 /* ImportDeclaration */ || node.parent.kind === 240 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -40040,7 +41298,7 @@ var ts; // Fall through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 174 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -40057,7 +41315,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 254 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 257 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -40119,28 +41377,28 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 172 /* ObjectLiteralExpression */ || expr.kind === 171 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 175 /* ObjectLiteralExpression */ || expr.kind === 174 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 209 /* ForOfStatement */) { + if (expr.parent.kind === 212 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 188 /* BinaryExpression */) { + if (expr.parent.kind === 191 /* BinaryExpression */) { var iteratedType = checkExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 253 /* PropertyAssignment */) { + if (expr.parent.kind === 256 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 171 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 174 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; @@ -40190,9 +41448,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols_3 = []; - var name_23 = symbol.name; + var name_27 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_23); + var symbol = getPropertyOfType(t, name_27); if (symbol) { symbols_3.push(symbol); } @@ -40200,6 +41458,10 @@ var ts; return symbols_3; } else if (symbol.flags & 67108864 /* Transient */) { + if (symbol.leftSpread) { + var links = symbol; + return [links.leftSpread, links.rightSpread]; + } var target = void 0; var next = symbol; while (next = getSymbolLinks(next).target) { @@ -40272,7 +41534,7 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 256 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 260 /* SourceFile */) { var symbolFile = parentSymbol.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. @@ -40329,7 +41591,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 200 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 203 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -40375,16 +41637,16 @@ var ts; return true; } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return node.expression && node.expression.kind === 70 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -40394,7 +41656,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 256 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 260 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -40460,7 +41722,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 255 /* EnumMember */) { + if (node.kind === 259 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -40561,9 +41823,9 @@ var ts; if (startInDeclarationContainer) { // When resolving the name of a declaration as a value, we need to start resolution // at a point outside of the declaration. - var parent_14 = reference.parent; - if (ts.isDeclaration(parent_14) && reference === parent_14.name) { - location = getDeclarationContainer(parent_14); + var parent_13 = reference.parent; + if (ts.isDeclaration(parent_13) && reference === parent_13.name) { + location = getDeclarationContainer(parent_13); } } return resolveName(location, reference.text, 107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -40583,7 +41845,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 262144 /* FreshLiteral */); + return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 1048576 /* FreshLiteral */); } return false; } @@ -40637,7 +41899,8 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - writeLiteralConstValue: writeLiteralConstValue + writeLiteralConstValue: writeLiteralConstValue, + getJsxFactoryEntity: function () { return _jsxFactoryEntity; } }; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -40648,7 +41911,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 173 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 176 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -40674,6 +41937,10 @@ var ts; if (typeReferenceDirective) { (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective); } + else { + // found at least one entry that does not originate from type reference directive + return undefined; + } } } return typeReferenceDirectives; @@ -40687,15 +41954,15 @@ var ts; // external modules cannot define or contribute to type declaration files var current = symbol; while (true) { - var parent_15 = getParentOfSymbol(current); - if (parent_15) { - current = parent_15; + var parent_14 = getParentOfSymbol(current); + if (parent_14) { + current = parent_14; } else { break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 256 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 260 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -40715,7 +41982,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 256 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 260 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -40748,7 +42015,7 @@ var ts; } } if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 31744 /* EmitHelperFlags */; + var fileRequestedExternalEmitHelpers = file.flags & 64512 /* EmitHelperFlags */; if (fileRequestedExternalEmitHelpers) { requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; if (firstFileRequestingExternalHelpers === undefined) { @@ -40827,9 +42094,13 @@ var ts; if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { verifyHelperSymbol(exports, "__extends", 107455 /* Value */); } - if (requestedExternalEmitHelpers & 16384 /* HasJsxSpreadAttributes */ && compilerOptions.jsx !== 1 /* Preserve */) { + if (requestedExternalEmitHelpers & 16384 /* HasSpreadAttribute */ && + (languageVersion < 5 /* ESNext */ || compilerOptions.jsx === 2 /* React */)) { verifyHelperSymbol(exports, "__assign", 107455 /* Value */); } + if (languageVersion < 5 /* ESNext */ && requestedExternalEmitHelpers & 32768 /* HasRestAttribute */) { + verifyHelperSymbol(exports, "__rest", 107455 /* Value */); + } if (requestedExternalEmitHelpers & 2048 /* HasDecorators */) { verifyHelperSymbol(exports, "__decorate", 107455 /* Value */); if (compilerOptions.emitDecoratorMetadata) { @@ -40878,14 +42149,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 148 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 149 /* 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 === 150 /* GetAccessor */ || node.kind === 151 /* SetAccessor */) { + else if (node.kind === 151 /* GetAccessor */ || node.kind === 152 /* 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); @@ -40902,17 +42173,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 !== 129 /* ReadonlyKeyword */) { - if (node.kind === 145 /* PropertySignature */ || node.kind === 147 /* MethodSignature */) { + if (modifier.kind !== 130 /* ReadonlyKeyword */) { + if (node.kind === 146 /* PropertySignature */ || node.kind === 148 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 75 /* ConstKeyword */: - if (node.kind !== 225 /* EnumDeclaration */ && node.parent.kind === 222 /* ClassDeclaration */) { + if (node.kind !== 228 /* EnumDeclaration */ && node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); } break; @@ -40938,7 +42209,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 === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -40961,10 +42232,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 === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + else if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -40973,11 +42244,11 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 146 /* PropertyDeclaration */ && node.kind !== 145 /* PropertySignature */ && node.kind !== 154 /* IndexSignature */ && node.kind !== 143 /* Parameter */) { + else if (node.kind !== 147 /* PropertyDeclaration */ && node.kind !== 146 /* PropertySignature */ && node.kind !== 155 /* IndexSignature */ && node.kind !== 144 /* 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); } @@ -40997,10 +42268,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; @@ -41012,13 +42283,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 227 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 230 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -41028,14 +42299,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 222 /* ClassDeclaration */) { - if (node.kind !== 148 /* MethodDeclaration */ && - node.kind !== 146 /* PropertyDeclaration */ && - node.kind !== 150 /* GetAccessor */ && - node.kind !== 151 /* SetAccessor */) { + if (node.kind !== 225 /* ClassDeclaration */) { + if (node.kind !== 149 /* MethodDeclaration */ && + node.kind !== 147 /* PropertyDeclaration */ && + node.kind !== 151 /* GetAccessor */ && + node.kind !== 152 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 222 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 225 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -41054,7 +42325,7 @@ var ts; else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 143 /* Parameter */) { + else if (node.kind === 144 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -41062,7 +42333,7 @@ var ts; break; } } - if (node.kind === 149 /* Constructor */) { + if (node.kind === 150 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -41077,13 +42348,13 @@ var ts; } return; } - else if ((node.kind === 231 /* ImportDeclaration */ || node.kind === 230 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 234 /* ImportDeclaration */ || node.kind === 233 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 144 /* 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 === 143 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 144 /* 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 */) { @@ -41103,37 +42374,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 154 /* IndexSignature */: - case 226 /* ModuleDeclaration */: - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: - case 236 /* ExportAssignment */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 143 /* Parameter */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 155 /* IndexSignature */: + case 229 /* ModuleDeclaration */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: + case 239 /* ExportAssignment */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 144 /* Parameter */: return false; default: - if (node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { return false; } switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 223 /* InterfaceDeclaration */: - case 201 /* VariableStatement */: - case 224 /* TypeAliasDeclaration */: + case 226 /* InterfaceDeclaration */: + case 204 /* VariableStatement */: + case 227 /* TypeAliasDeclaration */: return true; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); default: ts.Debug.fail(); @@ -41146,10 +42417,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 148 /* MethodDeclaration */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: if (!node.asteriskToken) { return false; } @@ -41212,7 +42483,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 181 /* ArrowFunction */) { + if (node.kind === 184 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -41247,7 +42518,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 !== 133 /* StringKeyword */ && parameter.type.kind !== 131 /* NumberKeyword */) { + if (parameter.type.kind !== 134 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -41275,7 +42546,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 194 /* OmittedExpression */) { + if (arg.kind === 197 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -41348,19 +42619,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 141 /* ComputedPropertyName */) { + if (node.kind !== 142 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 188 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 191 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 221 /* FunctionDeclaration */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 148 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 224 /* FunctionDeclaration */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 149 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -41385,12 +42656,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_24 = prop.name; - if (name_24.kind === 141 /* ComputedPropertyName */) { - // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_24); + if (prop.kind === 258 /* SpreadAssignment */) { + continue; } - if (prop.kind === 254 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + var name_28 = prop.name; + if (name_28.kind === 142 /* ComputedPropertyName */) { + // If the name is not a ComputedPropertyName, the grammar checking will skip it + checkGrammarComputedPropertyName(name_28); + } + if (prop.kind === 257 /* 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.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -41399,7 +42673,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 148 /* MethodDeclaration */) { + if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 149 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -41413,27 +42687,27 @@ var ts; // 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 = void 0; - if (prop.kind === 253 /* PropertyAssignment */ || prop.kind === 254 /* ShorthandPropertyAssignment */) { + if (prop.kind === 256 /* PropertyAssignment */ || prop.kind === 257 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_24.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_24); + if (name_28.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } - else if (prop.kind === 148 /* MethodDeclaration */) { + else if (prop.kind === 149 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 150 /* GetAccessor */) { + else if (prop.kind === 151 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 151 /* SetAccessor */) { + else if (prop.kind === 152 /* SetAccessor */) { currentKind = SetAccessor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_24); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -41443,18 +42717,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_24, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_24)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_24, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -41463,19 +42737,19 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 247 /* JsxSpreadAttribute */) { + if (attr.kind === 250 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; - var name_25 = jsxAttr.name; - if (!seen[name_25.text]) { - seen[name_25.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_25, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 248 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 251 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -41484,7 +42758,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 220 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 223 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -41499,20 +42773,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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 === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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 === 208 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 211 /* 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); @@ -41536,11 +42810,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 150 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 151 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 151 /* SetAccessor */) { + else if (kind === 152 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -41563,10 +42837,10 @@ var ts; A get accessor has no parameters or a single `this` parameter. 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 === 150 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 150 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 151 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -41581,7 +42855,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 172 /* ObjectLiteralExpression */) { + if (node.parent.kind === 175 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -41602,10 +42876,10 @@ var ts; return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol); } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 226 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 160 /* TypeLiteral */) { + else if (node.parent.kind === 161 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -41616,11 +42890,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 210 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 213 /* 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); @@ -41628,8 +42902,8 @@ var ts; return false; } break; - case 214 /* SwitchStatement */: - if (node.kind === 211 /* BreakStatement */ && !node.label) { + case 217 /* SwitchStatement */: + if (node.kind === 214 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -41644,13 +42918,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 211 /* BreakStatement */ + var message = node.kind === 214 /* 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 === 211 /* BreakStatement */ + var message = node.kind === 214 /* 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); @@ -41660,24 +42934,24 @@ var ts; if (node.dotDotDotToken) { var elements = node.parent.elements; if (node !== ts.lastOrUndefined(elements)) { - return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern); + return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 169 /* ArrayBindingPattern */ || node.name.kind === 168 /* ObjectBindingPattern */) { + if (node.name.kind === 172 /* ArrayBindingPattern */ || node.name.kind === 171 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { - // Error on equals token which immediate precedes the initializer + // Error on equals token which immediately precedes the initializer return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } } } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 186 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 189 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 208 /* ForInStatement */ && node.parent.parent.kind !== 209 /* ForOfStatement */) { + if (node.parent.parent.kind !== 211 /* ForInStatement */ && node.parent.parent.kind !== 212 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -41742,15 +43016,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 204 /* IfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 213 /* WithStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 207 /* IfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: return false; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -41805,7 +43079,7 @@ var ts; return true; } } - else if (node.parent.kind === 223 /* InterfaceDeclaration */) { + else if (node.parent.kind === 226 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41813,7 +43087,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 160 /* TypeLiteral */) { + else if (node.parent.kind === 161 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -41838,13 +43112,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 223 /* InterfaceDeclaration */ || - node.kind === 224 /* TypeAliasDeclaration */ || - node.kind === 231 /* ImportDeclaration */ || - node.kind === 230 /* ImportEqualsDeclaration */ || - node.kind === 237 /* ExportDeclaration */ || - node.kind === 236 /* ExportAssignment */ || - node.kind === 229 /* NamespaceExportDeclaration */ || + if (node.kind === 226 /* InterfaceDeclaration */ || + node.kind === 227 /* TypeAliasDeclaration */ || + node.kind === 234 /* ImportDeclaration */ || + node.kind === 233 /* ImportEqualsDeclaration */ || + node.kind === 240 /* ExportDeclaration */ || + node.kind === 239 /* ExportAssignment */ || + node.kind === 232 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -41853,7 +43127,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 === 201 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 204 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -41879,7 +43153,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 === 200 /* Block */ || node.parent.kind === 227 /* ModuleBlock */ || node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 203 /* Block */ || node.parent.kind === 230 /* ModuleBlock */ || node.parent.kind === 260 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -41939,49 +43213,49 @@ var ts; * significantly impacted. */ var nodeEdgeTraversalMap = ts.createMap((_a = {}, - _a[140 /* QualifiedName */] = [ + _a[141 /* QualifiedName */] = [ { name: "left", test: ts.isEntityName }, { name: "right", test: ts.isIdentifier } ], - _a[144 /* Decorator */] = [ + _a[145 /* Decorator */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[178 /* TypeAssertionExpression */] = [ + _a[181 /* TypeAssertionExpression */] = [ { name: "type", test: ts.isTypeNode }, { name: "expression", test: ts.isUnaryExpression } ], - _a[196 /* AsExpression */] = [ + _a[199 /* AsExpression */] = [ { name: "expression", test: ts.isExpression }, { name: "type", test: ts.isTypeNode } ], - _a[197 /* NonNullExpression */] = [ + _a[200 /* NonNullExpression */] = [ { name: "expression", test: ts.isLeftHandSideExpression } ], - _a[225 /* EnumDeclaration */] = [ + _a[228 /* EnumDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "members", test: ts.isEnumMember } ], - _a[226 /* ModuleDeclaration */] = [ + _a[229 /* ModuleDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isModuleName }, { name: "body", test: ts.isModuleBody } ], - _a[227 /* ModuleBlock */] = [ + _a[230 /* ModuleBlock */] = [ { name: "statements", test: ts.isStatement } ], - _a[230 /* ImportEqualsDeclaration */] = [ + _a[233 /* ImportEqualsDeclaration */] = [ { name: "decorators", test: ts.isDecorator }, { name: "modifiers", test: ts.isModifier }, { name: "name", test: ts.isIdentifier }, { name: "moduleReference", test: ts.isModuleReference } ], - _a[241 /* ExternalModuleReference */] = [ + _a[244 /* ExternalModuleReference */] = [ { name: "expression", test: ts.isExpression, optional: true } ], - _a[255 /* EnumMember */] = [ + _a[259 /* EnumMember */] = [ { name: "name", test: ts.isPropertyName }, { name: "initializer", test: ts.isExpression, optional: true, parenthesize: ts.parenthesizeExpressionForList } ], @@ -42004,47 +43278,47 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { + if ((kind >= 156 /* TypePredicate */ && kind <= 170 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: - case 287 /* NotEmittedStatement */: + case 202 /* SemicolonClassElement */: + case 205 /* EmptyStatement */: + case 197 /* OmittedExpression */: + case 221 /* DebuggerStatement */: + case 291 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: result = reduceNode(node.expression, f, result); break; // Signature elements - case 143 /* Parameter */: + case 144 /* Parameter */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 144 /* Decorator */: + case 145 /* Decorator */: result = reduceNode(node.expression, f, result); break; // Type member - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42053,12 +43327,12 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 149 /* Constructor */: + case 150 /* Constructor */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.body, f, result); break; - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42066,7 +43340,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42074,45 +43348,45 @@ var ts; result = reduceNode(node.body, f, result); break; // Binding patterns - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: result = ts.reduceLeft(node.elements, f, result); break; - case 170 /* BindingElement */: + case 173 /* BindingElement */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; // Expression - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: result = ts.reduceLeft(node.elements, f, result); break; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: result = ts.reduceLeft(node.properties, f, result); break; - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.name, f, result); break; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: result = reduceNode(node.expression, f, result); result = reduceNode(node.argumentExpression, f, result); break; - case 175 /* CallExpression */: + case 178 /* CallExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 176 /* NewExpression */: + case 179 /* NewExpression */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); result = ts.reduceLeft(node.arguments, f, result); break; - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: result = reduceNode(node.tag, f, result); result = reduceNode(node.template, f, result); break; - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); @@ -42120,119 +43394,119 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: result = ts.reduceLeft(node.modifiers, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.parameters, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 179 /* ParenthesizedExpression */: - case 182 /* DeleteExpression */: - case 183 /* TypeOfExpression */: - case 184 /* VoidExpression */: - case 185 /* AwaitExpression */: - case 191 /* YieldExpression */: - case 192 /* SpreadElementExpression */: - case 197 /* NonNullExpression */: + case 182 /* ParenthesizedExpression */: + case 185 /* DeleteExpression */: + case 186 /* TypeOfExpression */: + case 187 /* VoidExpression */: + case 188 /* AwaitExpression */: + case 194 /* YieldExpression */: + case 195 /* SpreadElement */: + case 200 /* NonNullExpression */: result = reduceNode(node.expression, f, result); break; - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: result = reduceNode(node.operand, f, result); break; - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: result = reduceNode(node.left, f, result); result = reduceNode(node.right, f, result); break; - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: result = reduceNode(node.condition, f, result); result = reduceNode(node.whenTrue, f, result); result = reduceNode(node.whenFalse, f, result); break; - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: result = reduceNode(node.head, f, result); result = ts.reduceLeft(node.templateSpans, f, result); break; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); result = ts.reduceLeft(node.typeParameters, f, result); result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, f, result); result = ts.reduceLeft(node.typeArguments, f, result); break; // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: result = reduceNode(node.expression, f, result); result = reduceNode(node.literal, f, result); break; // Element - case 200 /* Block */: + case 203 /* Block */: result = ts.reduceLeft(node.statements, f, result); break; - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.declarationList, f, result); break; - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: result = reduceNode(node.expression, f, result); break; - case 204 /* IfStatement */: + case 207 /* IfStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.thenStatement, f, result); result = reduceNode(node.elseStatement, f, result); break; - case 205 /* DoStatement */: + case 208 /* DoStatement */: result = reduceNode(node.statement, f, result); result = reduceNode(node.expression, f, result); break; - case 206 /* WhileStatement */: - case 213 /* WithStatement */: + case 209 /* WhileStatement */: + case 216 /* WithStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 207 /* ForStatement */: + case 210 /* ForStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.condition, f, result); result = reduceNode(node.incrementor, f, result); result = reduceNode(node.statement, f, result); break; - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: result = reduceNode(node.initializer, f, result); result = reduceNode(node.expression, f, result); result = reduceNode(node.statement, f, result); break; - case 212 /* ReturnStatement */: - case 216 /* ThrowStatement */: + case 215 /* ReturnStatement */: + case 219 /* ThrowStatement */: result = reduceNode(node.expression, f, result); break; - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: result = reduceNode(node.expression, f, result); result = reduceNode(node.caseBlock, f, result); break; - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: result = reduceNode(node.label, f, result); result = reduceNode(node.statement, f, result); break; - case 217 /* TryStatement */: + case 220 /* TryStatement */: result = reduceNode(node.tryBlock, f, result); result = reduceNode(node.catchClause, f, result); result = reduceNode(node.finallyBlock, f, result); break; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: result = reduceNode(node.name, f, result); result = reduceNode(node.type, f, result); result = reduceNode(node.initializer, f, result); break; - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: result = ts.reduceLeft(node.declarations, f, result); break; - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42241,7 +43515,7 @@ var ts; result = reduceNode(node.type, f, result); result = reduceNode(node.body, f, result); break; - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.name, f, result); @@ -42249,94 +43523,97 @@ var ts; result = ts.reduceLeft(node.heritageClauses, f, result); result = ts.reduceLeft(node.members, f, result); break; - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: result = ts.reduceLeft(node.clauses, f, result); break; - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.importClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; - case 232 /* ImportClause */: + case 235 /* ImportClause */: result = reduceNode(node.name, f, result); result = reduceNode(node.namedBindings, f, result); break; - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: result = reduceNode(node.name, f, result); break; - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: result = ts.reduceLeft(node.elements, f, result); break; - case 235 /* ImportSpecifier */: - case 239 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 242 /* ExportSpecifier */: result = reduceNode(node.propertyName, f, result); result = reduceNode(node.name, f, result); break; - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.expression, f, result); break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, f, result); result = ts.reduceLeft(node.modifiers, f, result); result = reduceNode(node.exportClause, f, result); result = reduceNode(node.moduleSpecifier, f, result); break; // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: result = reduceNode(node.openingElement, f, result); result = ts.reduceLeft(node.children, f, result); result = reduceNode(node.closingElement, f, result); break; - case 243 /* JsxSelfClosingElement */: - case 244 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 247 /* JsxOpeningElement */: result = reduceNode(node.tagName, f, result); result = ts.reduceLeft(node.attributes, f, result); break; - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: result = reduceNode(node.tagName, f, result); break; - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: result = reduceNode(node.expression, f, result); break; - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: result = reduceNode(node.expression, f, result); break; // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: result = reduceNode(node.expression, f, result); // fall-through - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: result = ts.reduceLeft(node.statements, f, result); break; - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: result = ts.reduceLeft(node.types, f, result); break; - case 252 /* CatchClause */: + case 255 /* CatchClause */: result = reduceNode(node.variableDeclaration, f, result); result = reduceNode(node.block, f, result); break; // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.initializer, f, result); break; - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, f, result); result = reduceNode(node.objectAssignmentInitializer, f, result); break; + case 258 /* SpreadAssignment */: + result = reduceNode(node.expression, f, result); + break; // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: result = ts.reduceLeft(node.statements, f, result); break; - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, f, result); break; default: @@ -42361,6 +43638,7 @@ var ts; if (node === undefined) { return undefined; } + aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; @@ -42409,6 +43687,7 @@ var ts; // Visit each original node. for (var i = 0; i < count; i++) { var node = nodes[i + start]; + aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -42447,192 +43726,194 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 139 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 140 /* LastToken */)) { return node; } // We do not yet support types. - if ((kind >= 155 /* TypePredicate */ && kind <= 167 /* LiteralType */)) { + if ((kind >= 156 /* TypePredicate */ && kind <= 170 /* LiteralType */)) { return node; } switch (node.kind) { - case 199 /* SemicolonClassElement */: - case 202 /* EmptyStatement */: - case 194 /* OmittedExpression */: - case 218 /* DebuggerStatement */: + case 202 /* SemicolonClassElement */: + case 205 /* EmptyStatement */: + case 197 /* OmittedExpression */: + case 221 /* DebuggerStatement */: // No need to visit nodes with no children. return node; // Names - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 143 /* Parameter */: - return ts.updateParameterDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 144 /* Parameter */: + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Type member - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 149 /* Constructor */: + case 150 /* Constructor */: return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 171 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 169 /* ArrayBindingPattern */: + case 172 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); // Expression - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, /*optional*/ true), context.endLexicalEnvironment())); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 192 /* SpreadElementExpression */: + case 195 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 200 /* Block */: + case 203 /* Block */: return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, /*optional*/ true), context.endLexicalEnvironment())); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 234 /* NamedImports */: + case 237 /* NamedImports */: return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 238 /* NamedExports */: + case 241 /* NamedExports */: return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNodes(node.attributes, visitor, ts.isJsxAttributeLike)); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 258 /* SpreadAssignment */: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: context.startLexicalEnvironment(); return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -42781,7 +44062,7 @@ var ts; * @param recordTempVariable A callback used to record new temporary variables. * @param visitor An optional visitor to use to visit expressions. */ - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor) { + function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { var right = node.right; if (ts.isDestructuringAssignment(right)) { @@ -42812,7 +44093,7 @@ var ts; // location should point to the right-hand value of the expression. location = value; } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); if (needsValue) { expressions.push(value); } @@ -42832,6 +44113,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectLiteral(elements), value, location); + } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; /** @@ -42841,9 +44125,9 @@ var ts; * @param value The rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenParameterDestructuring(node, value, visitor) { + function flattenParameterDestructuring(node, value, visitor, transformRest) { var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location) { var declaration = ts.createVariableDeclaration(name, /*type*/ undefined, value, location); @@ -42858,6 +44142,9 @@ var ts; emitAssignment(name, value, location); return name; } + function emitRestAssignment(elements, value, location) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location); + } } ts.flattenParameterDestructuring = flattenParameterDestructuring; /** @@ -42867,10 +44154,10 @@ var ts; * @param value An optional rhs value for the binding pattern. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuring(node, value, visitor, recordTempVariable) { + function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { var declarations = []; var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); return declarations; function emitAssignment(name, value, location, original) { if (pendingAssignments) { @@ -42902,6 +44189,9 @@ var ts; } return name; } + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); + } } ts.flattenVariableDestructuring = flattenVariableDestructuring; /** @@ -42909,36 +44199,40 @@ var ts; * * @param node The VariableDeclaration to flatten. * @param recordTempVariable A callback used to record new temporary variables. - * @param nameSubstitution An optional callback used to substitute binding names. + * @param createAssignmentCallback An optional callback used to create assignment expressions + * for non-temporary variables. * @param visitor An optional visitor to use to visit expressions. */ - function flattenVariableDestructuringToExpression(node, recordTempVariable, nameSubstitution, visitor) { + function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { var pendingAssignments = []; - flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor); + flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, /*transformRest*/ false, visitor); var expression = ts.inlineExpressions(pendingAssignments); ts.aggregateTransformFlags(expression); return expression; function emitAssignment(name, value, location, original) { - var left = nameSubstitution && nameSubstitution(name) || name; - emitPendingAssignment(left, value, location, original); + var expression = createAssignmentCallback + ? createAssignmentCallback(name.kind === 70 /* Identifier */ ? name : emitTempVariableAssignment(name, location), value, location) + : ts.createAssignment(name, value, location); + emitPendingAssignment(expression, original); } function emitTempVariableAssignment(value, location) { var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(name, value, location, /*original*/ undefined); + emitPendingAssignment(ts.createAssignment(name, value, location), /*original*/ undefined); return name; } - function emitPendingAssignment(name, value, location, original) { - var expression = ts.createAssignment(name, value, location); + function emitRestAssignment(elements, value, location, original) { + emitAssignment(ts.createObjectLiteral(elements), value, location, original); + } + function emitPendingAssignment(expression, original) { expression.original = original; // NOTE: this completely disables source maps, but aligns with the behavior of // `emitAssignment` in the old emitter. ts.setEmitFlags(expression, 2048 /* NoNestedSourceMaps */); pendingAssignments.push(expression); - return expression; } } ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, visitor) { + function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { if (value && visitor) { value = ts.visitNode(value, visitor, ts.isExpression); } @@ -42970,17 +44264,17 @@ var ts; else { target = bindingTarget; } - if (target.kind === 172 /* ObjectLiteralExpression */) { + if (target.kind === 175 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value, location); } - else if (target.kind === 171 /* ArrayLiteralExpression */) { + else if (target.kind === 174 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value, location); } else { - var name_26 = ts.getMutableClone(target); - ts.setSourceMapRange(name_26, target); - ts.setCommentRange(name_26, target); - emitAssignment(name_26, value, location, /*original*/ undefined); + var name_30 = ts.getMutableClone(target); + ts.setSourceMapRange(name_30, target); + ts.setCommentRange(name_30, target); + emitAssignment(name_30, value, location, /*original*/ undefined); } } function emitObjectLiteralAssignment(target, value, location) { @@ -42991,30 +44285,95 @@ var ts; // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); } - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; - if (p.kind === 253 /* PropertyAssignment */ || p.kind === 254 /* ShorthandPropertyAssignment */) { - var propName = p.name; - var target_1 = p.kind === 254 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; - // Assignment for target = value.propName should highligh whole property, hence use p as source map node - emitDestructuringAssignment(target_1, createDestructuringPropertyAccess(value, propName), p); + var bindingElements = []; + for (var i = 0; i < properties.length; i++) { + var p = properties[i]; + if (p.kind === 256 /* PropertyAssignment */ || p.kind === 257 /* ShorthandPropertyAssignment */) { + if (!transformRest || + p.transformFlags & 8388608 /* ContainsSpreadExpression */ || + (p.kind === 256 /* PropertyAssignment */ && p.initializer.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.name; + var bindingTarget = p.kind === 257 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; + // Assignment for bindingTarget = value.propName should highlight whole property, hence use p as source map node + emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); + } + else { + bindingElements.push(p); + } } + else if (i === properties.length - 1 && p.kind === 258 /* SpreadAssignment */) { + ts.Debug.assert(p.expression.kind === 70 /* Identifier */); + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; + } + var propName = p.expression; + var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); + emitDestructuringAssignment(propName, restCall, p); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, location, target); + bindingElements = []; } } function emitArrayLiteralAssignment(target, value, location) { + if (transformRest) { + emitESNextArrayLiteralAssignment(target, value, location); + } + else { + emitES2015ArrayLiteralAssignment(target, value, location); + } + } + function emitESNextArrayLiteralAssignment(target, value, location) { var elements = target.elements; var numElements = elements.length; if (numElements !== 1) { // For anything but a single element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. - // When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment + // When doing so we want to highlight the passed-in source map node since thats the one needing this temp assignment + value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); + } + var expressions = []; + var spreadContainingExpressions = []; + for (var i = 0; i < numElements; i++) { + var e = elements[i]; + if (e.kind === 197 /* OmittedExpression */) { + continue; + } + if (e.transformFlags & 8388608 /* ContainsSpreadExpression */ && i < numElements - 1) { + var tmp = ts.createTempVariable(recordTempVariable); + spreadContainingExpressions.push([e, tmp]); + expressions.push(tmp); + } + else { + expressions.push(e); + } + } + emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); + for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { + var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; + emitDestructuringAssignment(e, tmp, e); + } + } + function emitES2015ArrayLiteralAssignment(target, value, location) { + var elements = target.elements; + var numElements = elements.length; + if (numElements !== 1) { + // For anything but a single element destructuring we need to generate a temporary + // to ensure value is evaluated exactly once. + // When doing so we want to highlight the passed-in source map node since thats the one needing this temp assignment value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment); } for (var i = 0; i < numElements; i++) { var e = elements[i]; - if (e.kind !== 194 /* OmittedExpression */) { + if (e.kind !== 197 /* OmittedExpression */) { // Assignment for target = value.propName should highligh whole property, hence use e as source map node - if (e.kind !== 192 /* SpreadElementExpression */) { + if (e.kind !== 195 /* SpreadElement */) { emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); } else if (i === numElements - 1) { @@ -43023,10 +44382,30 @@ var ts; } } } + /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement + * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ + function createRestCall(value, elements, getPropertyName, location) { + var propertyNames = []; + for (var i = 0; i < elements.length - 1; i++) { + if (ts.isOmittedExpression(elements[i])) { + continue; + } + var str = ts.createSynthesizedNode(9 /* StringLiteral */); + str.pos = location.pos; + str.end = location.end; + str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); + propertyNames.push(str); + } + var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); + return ts.createCall(ts.createIdentifier("__rest"), undefined, args); + } function emitBindingElement(target, value) { // Any temporary assignments needed to emit target = value should point to target var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (initializer) { + if (transformRest) { + value = value || initializer; + } + else if (initializer) { // Combine value and initializer value = value ? createDefaultValueCheck(value, initializer, target) : initializer; } @@ -43035,9 +44414,11 @@ var ts; value = ts.createVoidZero(); } var name = target.name; - if (ts.isBindingPattern(name)) { - var elements = name.elements; - var numElements = elements.length; + if (!ts.isBindingPattern(name)) { + emitAssignment(name, value, target, target); + } + else { + var numElements = name.elements.length; if (numElements !== 1) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -43045,29 +44426,98 @@ var ts; // so in that case, we'll intentionally create that temporary. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0, target, emitTempVariableAssignment); } - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - else if (name.kind === 168 /* ObjectBindingPattern */) { - // Rewrite element to a declaration with an initializer that fetches property - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } - else { - if (!element.dotDotDotToken) { - // Rewrite element to a declaration that accesses array element at index i - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + if (name.kind === 172 /* ArrayBindingPattern */) { + emitArrayBindingElement(name, value); + } + else { + emitObjectBindingElement(target, value); } } + } + function emitArrayBindingElement(name, value) { + if (transformRest) { + emitESNextArrayBindingElement(name, value); + } else { - emitAssignment(name, value, target, target); + emitES2015ArrayBindingElement(name, value); + } + } + function emitES2015ArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (!element.dotDotDotToken) { + // Rewrite element to a declaration that accesses array element at index i + emitBindingElement(element, ts.createElementAccess(value, i)); + } + else if (i === numElements - 1) { + emitBindingElement(element, ts.createArraySlice(value, i)); + } + } + } + function emitESNextArrayBindingElement(name, value) { + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + var spreadContainingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (element.transformFlags & 8388608 /* ContainsSpreadExpression */ && i < numElements - 1) { + spreadContainingElements.push(element); + bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + } + else { + bindingElements.push(element); + } + } + emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); + for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { + var element = spreadContainingElements_1[_i]; + emitBindingElement(element, ts.getGeneratedNameForNode(element)); + } + } + function emitObjectBindingElement(target, value) { + var name = target.name; + var elements = name.elements; + var numElements = elements.length; + var bindingElements = []; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (ts.isOmittedExpression(element)) { + continue; + } + if (i === numElements - 1 && element.dotDotDotToken) { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); + emitBindingElement(element, restCall); + } + else if (transformRest && !(element.transformFlags & 8388608 /* ContainsSpreadExpression */)) { + // do not emit until we have a complete bundle of ES2015 syntax + bindingElements.push(element); + } + else { + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; + } + // Rewrite element to a declaration with an initializer that fetches property + var propName = element.propertyName || element.name; + emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); + } + } + if (bindingElements.length) { + emitRestAssignment(bindingElements, value, target, target); + bindingElements = []; } } function createDefaultValueCheck(value, defaultValue, location) { @@ -43158,15 +44608,15 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(174 /* ElementAccessExpression */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(177 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentSourceFileExternalHelpersModuleName; + var currentExternalHelpersModuleName; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -43227,7 +44677,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.kind === 256 /* SourceFile */) { + if (node.kind === 260 /* SourceFile */) { return visitSourceFile(node); } else if (node.transformFlags & 1 /* TypeScript */) { @@ -43255,13 +44705,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return visitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -43281,11 +44731,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 237 /* ExportDeclaration */ || - node.kind === 231 /* ImportDeclaration */ || - node.kind === 232 /* ImportClause */ || - (node.kind === 230 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 241 /* ExternalModuleReference */)) { + if (node.kind === 240 /* ExportDeclaration */ || + node.kind === 234 /* ImportDeclaration */ || + node.kind === 235 /* ImportClause */ || + (node.kind === 233 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 244 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -43315,25 +44765,34 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 149 /* Constructor */: + case 150 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 146 /* PropertyDeclaration */: - case 154 /* IndexSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 148 /* MethodDeclaration */: + case 147 /* PropertyDeclaration */: + case 155 /* IndexSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 149 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); return undefined; } } + function modifierVisitor(node) { + if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + return undefined; + } + else if (currentNamespace && node.kind === 83 /* ExportKeyword */) { + return undefined; + } + return node; + } /** * Branching visitor, visits a TypeScript syntax node. * @@ -43356,45 +44815,47 @@ var ts; case 116 /* AbstractKeyword */: case 75 /* ConstKeyword */: case 123 /* DeclareKeyword */: - case 129 /* ReadonlyKeyword */: + case 130 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 161 /* ArrayType */: - case 162 /* TupleType */: - case 160 /* TypeLiteral */: - case 155 /* TypePredicate */: - case 142 /* TypeParameter */: + case 162 /* ArrayType */: + case 163 /* TupleType */: + case 161 /* TypeLiteral */: + case 156 /* TypePredicate */: + case 143 /* TypeParameter */: case 118 /* AnyKeyword */: case 121 /* BooleanKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: - case 128 /* NeverKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: + case 129 /* NeverKeyword */: case 104 /* VoidKeyword */: - case 134 /* SymbolKeyword */: - case 158 /* ConstructorType */: - case 157 /* FunctionType */: - case 159 /* TypeQuery */: - case 156 /* TypeReference */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: - case 165 /* ParenthesizedType */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 135 /* SymbolKeyword */: + case 159 /* ConstructorType */: + case 158 /* FunctionType */: + case 160 /* TypeQuery */: + case 157 /* TypeReference */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: + case 166 /* ParenthesizedType */: + case 167 /* ThisType */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 170 /* LiteralType */: // TypeScript type nodes are elided. - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: // TypeScript index signatures are elided. - case 144 /* Decorator */: + case 145 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: // TypeScript property declarations are elided. - case 149 /* Constructor */: + case 150 /* Constructor */: return visitConstructor(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43405,7 +44866,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -43416,35 +44877,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 150 /* GetAccessor */: + case 151 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 143 /* Parameter */: + case 144 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -43454,33 +44915,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 178 /* TypeAssertionExpression */: - case 196 /* AsExpression */: + case 181 /* TypeAssertionExpression */: + case 199 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -43495,15 +44956,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 256 /* SourceFile */: - case 228 /* CaseBlock */: - case 227 /* ModuleBlock */: - case 200 /* Block */: + case 260 /* SourceFile */: + case 231 /* CaseBlock */: + case 230 /* ModuleBlock */: + case 203 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 222 /* ClassDeclaration */: - case 221 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: + case 224 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -43514,13 +44975,17 @@ var ts; function visitSourceFile(node) { currentSourceFile = node; // ensure "use strict" is emitted in all scenarios in alwaysStrict mode - if (compilerOptions.alwaysStrict) { + // There is no need to emit "use strict" in the following cases: + // 1. The file is an external module and target is es2015 or higher + // or 2. The file is an external module and module-kind is es6 or es2015 as such value is not allowed when targeting es5 or lower + if (compilerOptions.alwaysStrict && + !(ts.isExternalModule(node) && (compilerOptions.target >= 2 /* ES2015 */ || compilerOptions.module === ts.ModuleKind.ES2015))) { node = ts.ensureUseStrict(node); } // If the source file requires any helpers and is an external module, and // the importHelpers compiler option is enabled, emit a synthesized import // statement for the helpers library. - if (node.flags & 31744 /* EmitHelperFlags */ + if (node.flags & 64512 /* EmitHelperFlags */ && compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { startLexicalEnvironment(); @@ -43533,10 +44998,10 @@ var ts; externalHelpersModuleImport.parent = node; externalHelpersModuleImport.flags &= ~8 /* Synthesized */; statements.push(externalHelpersModuleImport); - currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; + currentExternalHelpersModuleName = externalHelpersModuleName; ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); - currentSourceFileExternalHelpersModuleName = undefined; + currentExternalHelpersModuleName = undefined; node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); node.externalHelpersModuleName = externalHelpersModuleName; } @@ -43580,7 +45045,6 @@ var ts; var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); - var classAlias; // emit name if // - node has a name // - node has static initializers @@ -43589,38 +45053,22 @@ var ts; if (!name && staticProperties.length > 0) { name = ts.getGeneratedNameForNode(node); } - var statements = []; - if (!isDecoratedClass) { - // ${modifiers} class ${name} ${heritageClauses} { - // ${members} - // } - var classDeclaration = ts.createClassDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), - /*location*/ node); - ts.setOriginalNode(classDeclaration, node); - // To better align with the old emitter, we should not emit a trailing source map - // entry if the class has static properties. - if (staticProperties.length > 0) { - ts.setEmitFlags(classDeclaration, 1024 /* NoTrailingSourceMap */ | ts.getEmitFlags(classDeclaration)); - } - statements.push(classDeclaration); - } - else { - classAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); - } + var classStatement = isDecoratedClass + ? createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) + : createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, staticProperties.length > 0); + var statements = [classStatement]; // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (staticProperties.length) { - addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + addInitializedPropertyStatements(statements, staticProperties, ts.getLocalName(node)); } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node, classAlias); + addConstructorDecorationStatement(statements, node); // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. @@ -43629,26 +45077,54 @@ var ts; } else if (isDecoratedClass) { if (isDefaultExternalModuleExport(node)) { - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getLocalName(node))); + statements.push(ts.createExportDefault(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } else if (isNamedExternalModuleExport(node)) { - statements.push(createExternalModuleExport(name)); + statements.push(ts.createExternalModuleExport(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } - return statements; + if (statements.length > 1) { + // Add a DeclarationMarker as a marker for the end of the declaration + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432 /* HasEndOfDeclarationMarker */); + } + return ts.singleOrMany(statements); + } + /** + * Transforms a non-decorated class declaration and appends the resulting statements. + * + * @param node A ClassDeclaration node. + * @param name The name of the class. + * @param hasExtendsClause A value indicating whether the class has an extends clause. + * @param hasStaticProperties A value indicating whether the class has static properties. + */ + function createClassDeclarationHeadWithoutDecorators(node, name, hasExtendsClause, hasStaticProperties) { + // ${modifiers} class ${name} ${heritageClauses} { + // ${members} + // } + var classDeclaration = ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); + var emitFlags = ts.getEmitFlags(node); + // To better align with the old emitter, we should not emit a trailing source map + // entry if the class has static properties. + if (hasStaticProperties) { + emitFlags |= 1024 /* NoTrailingSourceMap */; + } + ts.setOriginalNode(classDeclaration, node); + ts.setEmitFlags(classDeclaration, emitFlags); + return classDeclaration; } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. * + * @param statements A statement list to which to add the declaration. * @param node A ClassDeclaration node. * @param name The name of the class. - * @param hasExtendsClause A value indicating whether + * @param hasExtendsClause A value indicating whether the class has an extends clause. */ - function addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause) { + function createClassDeclarationHeadWithDecorators(node, name, hasExtendsClause) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -43683,20 +45159,20 @@ var ts; // --------------------------------------------------------------------- // TypeScript | Javascript // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = C_1 = class C { // class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); + // | var C_1; // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = class C { // export class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); // | export { C }; + // | var C_1; // --------------------------------------------------------------------- // // If a class declaration is the default export of a module, we instead emit @@ -43725,59 +45201,31 @@ var ts; // --------------------------------------------------------------------- // TypeScript | Javascript // --------------------------------------------------------------------- - // @dec | let C_1 = class C { + // @dec | let C = class C { // export default class C { | static x() { return C_1.y; } // static x() { return C.y; } | } - // static y = 1; | let C = C_1; - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); + // static y = 1; | C.y = 1; + // } | C = C_1 = __decorate([dec], C); // | export default C; + // | var C_1; // --------------------------------------------------------------------- // var location = ts.moveRangePastDecorators(node); + var classAlias = getClassAliasIfNeeded(node); + var declName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { // ${members} // } - var classExpression = ts.setOriginalNode(ts.createClassExpression( - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), - /*location*/ location), node); - if (!name) { - name = ts.getGeneratedNameForNode(node); - } - // Record an alias to avoid class double-binding. - var classAlias; - if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { - enableSubstitutionForClassAliases(); - classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); - classAliases[ts.getOriginalNodeId(node)] = classAlias; - } - var declaredName = getDeclarationName(node, /*allowComments*/ true); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = transformClassMembers(node, hasExtendsClause); + var classExpression = ts.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members, location); + ts.setOriginalNode(classExpression, node); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - var transformedClassExpression = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(classAlias || declaredName, - /*type*/ undefined, classExpression) - ]), - /*location*/ location); - ts.setCommentRange(transformedClassExpression, node); - statements.push(ts.setOriginalNode( - /*node*/ transformedClassExpression, - /*original*/ node)); - if (classAlias) { - // We emit the class alias as a `let` declaration here so that it has the same - // TDZ as the class. - // let ${declaredName} = ${decoratedClassAlias} - statements.push(ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createLetDeclarationList([ - ts.createVariableDeclaration(declaredName, - /*type*/ undefined, classAlias) - ]), - /*location*/ location), - /*original*/ node)); - } - return classAlias; + var statement = ts.createLetStatement(declName, classAlias ? ts.createAssignment(classAlias, classExpression) : classExpression, location); + ts.setOriginalNode(statement, node); + ts.setCommentRange(statement, node); + return statement; } /** * Transforms a class expression with TypeScript syntax into compatible ES6. @@ -43840,7 +45288,7 @@ var ts; // If there is a property assignment, we need to emit constructor whether users define it or not // If there is no property assignment, we can omit constructor if users do not define it var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 524288 /* ContainsParameterPropertyAssignments */; + var hasParameterPropertyAssignments = node.transformFlags & 4194304 /* ContainsParameterPropertyAssignments */; var constructor = ts.getFirstConstructorWithBody(node); // If the class does not contain nodes that require a synthesized constructor, // accept the current constructor if it exists. @@ -43960,7 +45408,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -44033,7 +45481,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 146 /* PropertyDeclaration */ + return member.kind === 147 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -44168,12 +45616,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -44325,11 +45773,11 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 146 /* PropertyDeclaration */ + ? member.kind === 147 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); ts.setEmitFlags(helper, 49152 /* NoComments */); return helper; } @@ -44338,8 +45786,8 @@ var ts; * * @param node The class node. */ - function addConstructorDecorationStatement(statements, node, decoratedClassAlias) { - var expression = generateConstructorDecorationExpression(node, decoratedClassAlias); + function addConstructorDecorationStatement(statements, node) { + var expression = generateConstructorDecorationExpression(node); if (expression) { statements.push(ts.setOriginalNode(ts.createStatement(expression), node)); } @@ -44349,33 +45797,19 @@ var ts; * * @param node The class node. */ - function generateConstructorDecorationExpression(node, decoratedClassAlias) { + function generateConstructorDecorationExpression(node) { var allDecorators = getAllDecoratorsOfConstructor(node); var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators); if (!decoratorExpressions) { return undefined; } - // Emit the call to __decorate. Given the class: - // - // @dec - // class C { - // } - // - // The emit for the class is: - // - // C = C_1 = __decorate([dec], C); - // - if (decoratedClassAlias) { - var expression = ts.createAssignment(decoratedClassAlias, ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node))); - var result = ts.createAssignment(getDeclarationName(node), expression, ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152 /* NoComments */); - return result; - } - else { - var result = ts.createAssignment(getDeclarationName(node), ts.createDecorateHelper(currentSourceFileExternalHelpersModuleName, decoratorExpressions, getDeclarationName(node)), ts.moveRangePastDecorators(node)); - ts.setEmitFlags(result, 49152 /* NoComments */); - return result; - } + var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); + ts.setEmitFlags(expression, 49152 /* NoComments */); + ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); + return expression; } /** * Transforms a decorator into an expression. @@ -44397,7 +45831,7 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentSourceFileExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, + var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, /*location*/ decorator.expression); ts.setEmitFlags(helper, 49152 /* NoComments */); expressions.push(helper); @@ -44422,13 +45856,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -44436,16 +45870,16 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeParameterTypesOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, /*equalsGreaterThanToken*/ undefined, serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentSourceFileExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); + decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, /*location*/ undefined, /*multiLine*/ true))); } } } @@ -44458,10 +45892,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */ - || kind === 146 /* PropertyDeclaration */; + return kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */ + || kind === 147 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -44471,7 +45905,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 148 /* MethodDeclaration */; + return node.kind === 149 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -44482,11 +45916,11 @@ var ts; */ function shouldAddParamTypesMetadata(node) { var kind = node.kind; - return kind === 222 /* ClassDeclaration */ - || kind === 193 /* ClassExpression */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */; + return kind === 225 /* ClassDeclaration */ + || kind === 196 /* ClassExpression */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Serializes the type of a node for use with decorator type metadata. @@ -44495,15 +45929,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: - case 150 /* GetAccessor */: + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: + case 151 /* GetAccessor */: return serializeTypeNode(node.type); - case 151 /* SetAccessor */: + case 152 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 148 /* MethodDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 149 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -44516,10 +45950,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 161 /* ArrayType */) { + if (node && node.kind === 162 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 156 /* TypeReference */) { + else if (node && node.kind === 157 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -44595,20 +46029,20 @@ var ts; switch (node.kind) { case 104 /* VoidKeyword */: return ts.createVoidZero(); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return ts.createIdentifier("Function"); - case 161 /* ArrayType */: - case 162 /* TupleType */: + case 162 /* ArrayType */: + case 163 /* TupleType */: return ts.createIdentifier("Array"); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: case 121 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 133 /* StringKeyword */: + case 134 /* StringKeyword */: return ts.createIdentifier("String"); - case 167 /* LiteralType */: + case 170 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -44622,16 +46056,16 @@ var ts; break; } break; - case 131 /* NumberKeyword */: + case 132 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return serializeTypeReferenceNode(node); - case 164 /* IntersectionType */: - case 163 /* UnionType */: + case 165 /* IntersectionType */: + case 164 /* UnionType */: { var unionOrIntersection = node; var serializedUnion = void 0; @@ -44660,10 +46094,12 @@ var ts; } } // Fallthrough - case 159 /* TypeQuery */: - case 160 /* TypeLiteral */: + case 160 /* TypeQuery */: + case 168 /* TypeOperator */: + case 169 /* IndexedAccessType */: + case 161 /* TypeLiteral */: case 118 /* AnyKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44720,15 +46156,15 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_27 = ts.getMutableClone(node); - name_27.flags &= ~8 /* Synthesized */; - name_27.original = undefined; - name_27.parent = currentScope; + var name_31 = ts.getMutableClone(node); + name_31.flags &= ~8 /* Synthesized */; + name_31.original = undefined; + name_31.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_27), ts.createLiteral("undefined")), name_27); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); } - return name_27; - case 140 /* QualifiedName */: + return name_31; + case 141 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -44861,7 +46297,7 @@ var ts; return undefined; } var method = ts.createMethod( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44895,14 +46331,14 @@ var ts; return undefined; } var accessor = ts.createGetAccessor( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } /** @@ -44919,13 +46355,13 @@ var ts; return undefined; } var accessor = ts.createSetAccessor( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), /*location*/ node); // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. + ts.setOriginalNode(accessor, node); ts.setCommentRange(accessor, node); ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(accessor, node); return accessor; } /** @@ -44943,7 +46379,7 @@ var ts; return ts.createNotEmittedStatement(node); } var func = ts.createFunctionDeclaration( - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44967,7 +46403,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, transformFunctionBody(node), /*location*/ node); @@ -44980,7 +46416,7 @@ var ts; * - The node has type annotations */ function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), + var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), /*type*/ undefined, node.equalsGreaterThanToken, transformConciseBody(node), /*location*/ node); @@ -45040,7 +46476,7 @@ var ts; if (ts.parameterIsThisKeyword(node)) { return undefined; } - var parameter = ts.createParameterDeclaration( + var parameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName), /*questionToken*/ undefined, @@ -45077,7 +46513,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getNamespaceMemberNameWithSourceMapsAndWithoutComments, visitor); + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), @@ -45143,21 +46579,6 @@ var ts; || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules; } - function shouldEmitVarForEnumDeclaration(node) { - return isFirstEmittedDeclarationInScope(node) - && (!ts.hasModifier(node, 1 /* Export */) - || isES6ExportedDeclaration(node)); - } - /* - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForEnumExportedFromNamespace(statements, node) { - var statement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, getExportName(node))]); - ts.setSourceMapRange(statement, node); - statements.push(statement); - } /** * Visits an enum declaration. * @@ -45176,9 +46597,7 @@ var ts; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForEnumDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384 /* NoLeadingComments */; @@ -45189,7 +46608,18 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1 /* Export */) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) + : ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // x || (x = {}) + // exports.x || (exports.x = {}) + var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); + if (hasNamespaceQualifiedExportName(node)) { + // `localName` is the expression used within this node's containing scope for any local references. + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + // x = (exports.x || (exports.x = {})) + moduleArg = ts.createAssignment(localName, moduleArg); + } // (function (x) { // x[x["y"] = 0] = "y"; // ... @@ -45198,16 +46628,16 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName)), - /*typeArguments*/ undefined, [ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral()))]), + /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(enumStatement, node); ts.setEmitFlags(enumStatement, emitFlags); statements.push(enumStatement); - if (isNamespaceExport(node)) { - addVarForEnumExportedFromNamespace(statements, node); - } + // Add a DeclarationMarker for the enum to preserve trailing comments and mark + // the end of the declaration. + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } /** @@ -45269,9 +46699,15 @@ var ts; function shouldEmitModuleDeclaration(node) { return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } - function isES6ExportedDeclaration(node) { - return isExternalModuleExport(node) - && moduleKind === ts.ModuleKind.ES2015; + /** + * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` + * or `exports.x`). + */ + function hasNamespaceQualifiedExportName(node) { + return isNamespaceExport(node) + || (isExternalModuleExport(node) + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.System); } /** * Records that a declaration was emitted in the current scope, if it was the first @@ -45297,55 +46733,64 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_28 = node.symbol && node.symbol.name; - if (name_28) { - return currentScopeFirstDeclarationsOfName[name_28] === node; + var name_32 = node.symbol && node.symbol.name; + if (name_32) { + return currentScopeFirstDeclarationsOfName[name_32] === node; } } return false; } - function shouldEmitVarForModuleDeclaration(node) { - return isFirstEmittedDeclarationInScope(node); - } /** * Adds a leading VariableStatement for a enum or module declaration. */ function addVarForEnumOrModuleDeclaration(statements, node) { // Emit a variable statement for the module. - var statement = ts.createVariableStatement(isES6ExportedDeclaration(node) - ? ts.visitNodes(node.modifiers, visitor, ts.isModifier) - : undefined, [ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) + var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), [ + ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) ]); - ts.setOriginalNode(statement, /*original*/ node); - // Adjust the source map emit to match the old emitter. - if (node.kind === 225 /* EnumDeclaration */) { - ts.setSourceMapRange(statement.declarationList, node); + ts.setOriginalNode(statement, node); + recordEmittedDeclarationInScope(node); + if (isFirstEmittedDeclarationInScope(node)) { + // Adjust the source map emit to match the old emitter. + if (node.kind === 228 /* EnumDeclaration */) { + ts.setSourceMapRange(statement.declarationList, node); + } + else { + ts.setSourceMapRange(statement, node); + } + // Trailing comments for module declaration should be emitted after the function closure + // instead of the variable statement: + // + // /** Module comment*/ + // module m1 { + // function foo4Export() { + // } + // } // trailing comment module + // + // Should emit: + // + // /** Module comment*/ + // var m1; + // (function (m1) { + // function foo4Export() { + // } + // })(m1 || (m1 = {})); // trailing comment module + // + ts.setCommentRange(statement, node); + ts.setEmitFlags(statement, 32768 /* NoTrailingComments */ | 33554432 /* HasEndOfDeclarationMarker */); + statements.push(statement); + return true; } else { - ts.setSourceMapRange(statement, node); + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrap the leading variable declaration in a `MergeDeclarationMarker`. + var mergeMarker = ts.createMergeDeclarationMarker(statement); + ts.setEmitFlags(mergeMarker, 49152 /* NoComments */ | 33554432 /* HasEndOfDeclarationMarker */); + statements.push(mergeMarker); + return false; } - // Trailing comments for module declaration should be emitted after the function closure - // instead of the variable statement: - // - // /** Module comment*/ - // module m1 { - // function foo4Export() { - // } - // } // trailing comment module - // - // Should emit: - // - // /** Module comment*/ - // var m1; - // (function (m1) { - // function foo4Export() { - // } - // })(m1 || (m1 = {})); // trailing comment module - // - ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768 /* NoTrailingComments */); - statements.push(statement); } /** * Visits a module declaration node. @@ -45367,9 +46812,7 @@ var ts; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. - recordEmittedDeclarationInScope(node); - if (shouldEmitVarForModuleDeclaration(node)) { - addVarForEnumOrModuleDeclaration(statements, node); + if (addVarForEnumOrModuleDeclaration(statements, node)) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { emitFlags |= 16384 /* NoLeadingComments */; @@ -45380,13 +46823,15 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = getExportName(node); + var exportName = ts.hasModifier(node, 1 /* Export */) + ? ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) + : ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) // exports.x || (exports.x = {}) var moduleArg = ts.createLogicalOr(exportName, ts.createAssignment(exportName, ts.createObjectLiteral())); - if (ts.hasModifier(node, 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if (hasNamespaceQualifiedExportName(node)) { // `localName` is the expression used within this node's containing scope for any local references. - var localName = getLocalName(node); + var localName = ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x = (exports.x || (exports.x = {})) moduleArg = ts.createAssignment(localName, moduleArg); } @@ -45397,13 +46842,16 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName)), /*typeArguments*/ undefined, [moduleArg]), /*location*/ node); ts.setOriginalNode(moduleStatement, node); ts.setEmitFlags(moduleStatement, emitFlags); statements.push(moduleStatement); + // Add a DeclarationMarker for the namespace to preserve trailing comments and mark + // the end of the declaration. + statements.push(ts.createEndOfDeclarationMarker(node)); return statements; } /** @@ -45423,7 +46871,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 227 /* ModuleBlock */) { + if (body.kind === 230 /* ModuleBlock */) { ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); statementsLocation = body.statements; blockLocation = body; @@ -45469,13 +46917,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 (body.kind !== 227 /* ModuleBlock */) { + if (body.kind !== 230 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 229 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -45516,7 +46964,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 233 /* NamespaceImport */) { + if (node.kind === 236 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -45623,9 +47071,9 @@ var ts; if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; - return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.createVariableDeclarationList([ - ts.createVariableDeclaration(node.name, - /*type*/ undefined, moduleReference) + return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ + ts.setOriginalNode(ts.createVariableDeclaration(node.name, + /*type*/ undefined, moduleReference), node) ]), node), node); } else { @@ -45674,38 +47122,20 @@ var ts; return ts.createStatement(expression, /*location*/ undefined); } function addExportMemberAssignment(statements, node) { - var expression = ts.createAssignment(getExportName(node), getLocalName(node, /*noSourceMaps*/ true)); + var expression = ts.createAssignment(ts.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), ts.getLocalName(node)); ts.setSourceMapRange(expression, ts.createRange(node.name.pos, node.end)); var statement = ts.createStatement(expression); ts.setSourceMapRange(statement, ts.createRange(-1, node.end)); statements.push(statement); } function createNamespaceExport(exportName, exportValue, location) { - return ts.createStatement(ts.createAssignment(getNamespaceMemberName(exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); + return ts.createStatement(ts.createAssignment(ts.getNamespaceMemberName(currentNamespaceContainerName, exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue), location); } - function createExternalModuleExport(exportName) { - return ts.createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createNamedExports([ - ts.createExportSpecifier(exportName) - ])); - } - function getNamespaceMemberName(name, allowComments, allowSourceMaps) { - var qualifiedName = ts.createPropertyAccess(currentNamespaceContainerName, ts.getSynthesizedClone(name), /*location*/ name); - var emitFlags; - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (emitFlags) { - ts.setEmitFlags(qualifiedName, emitFlags); - } - return qualifiedName; + function createNamespaceExportExpression(exportName, exportValue, location) { + return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue, location); } function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) { - return getNamespaceMemberName(name, /*allowComments*/ false, /*allowSourceMaps*/ true); + return ts.getNamespaceMemberName(currentNamespaceContainerName, name, /*allowComments*/ false, /*allowSourceMaps*/ true); } /** * Gets the declaration name used inside of a namespace or enum. @@ -45723,67 +47153,25 @@ var ts; return ts.getGeneratedNameForNode(node); } /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. - * @param allowComments A value indicating whether comments may be emitted for the name. + * Gets a local alias for a class declaration if it is a decorated class with an internal + * reference to the static side of the class. This is necessary to avoid issues with + * double-binding semantics for the class name. */ - function getLocalName(node, noSourceMaps, allowComments) { - return getDeclarationName(node, allowComments, !noSourceMaps, 262144 /* LocalName */); - } - /** - * Gets the export name for a declaration for use in expressions. - * - * An export name will *always* be prefixed with an module or namespace export modifier - * like "exports." if one is required. - * - * @param node The declaration. - * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. - * @param allowComments A value indicating whether comments may be emitted for the name. - */ - function getExportName(node, noSourceMaps, allowComments) { - if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); - } - return getDeclarationName(node, allowComments, !noSourceMaps, 131072 /* ExportName */); - } - /** - * Gets the name for a declaration for use in declarations. - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - * @param emitFlags Additional NodeEmitFlags to specify for the name. - */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name) { - var name_29 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_29, emitFlags); - } - return name_29; - } - else { - return ts.getGeneratedNameForNode(node); + function getClassAliasIfNeeded(node) { + if (resolver.getNodeCheckFlags(node) & 8388608 /* ClassWithConstructorReference */) { + enableSubstitutionForClassAliases(); + var classAlias = ts.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? node.name.text : "default"); + classAliases[ts.getOriginalNodeId(node)] = classAlias; + hoistVariableDeclaration(classAlias); + return classAlias; } } function getClassPrototype(node) { - return ts.createPropertyAccess(getDeclarationName(node), "prototype"); + return ts.createPropertyAccess(ts.getDeclarationName(node), "prototype"); } function getClassMemberPrefix(node, member) { return ts.hasModifier(member, 32 /* Static */) - ? getDeclarationName(node) + ? ts.getDeclarationName(node) : getClassPrototype(node); } function enableSubstitutionForNonQualifiedEnumMembers() { @@ -45808,20 +47196,21 @@ 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(70 /* Identifier */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); + context.enableSubstitution(257 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(226 /* ModuleDeclaration */); + context.enableEmitNotification(229 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 226 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 229 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 225 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 228 /* EnumDeclaration */; } /** * Hook for node emit. * + * @param emitContext A context hint for the emitter. * @param node The node to emit. * @param emit A callback used to emit the node in the printer. */ @@ -45839,9 +47228,8 @@ var ts; /** * Hooks node substitutions. * + * @param emitContext A context hint for the emitter. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -45855,16 +47243,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_30 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_30); + var name_33 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_33); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_30, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_33, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_30, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_33, exportedName, /*location*/ node); } } return node; @@ -45873,9 +47261,9 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return substituteExpressionIdentifier(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -45909,13 +47297,13 @@ var ts; } function trySubstituteNamespaceExportedName(node) { // If this is explicitly a local name, do not substitute. - if (enabledSubstitutions & applicableSubstitutions && (ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { // 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) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 226 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 225 /* EnumDeclaration */); + if (container && container.kind !== 260 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 229 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 228 /* EnumDeclaration */); if (substitute) { return ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node, /*location*/ node); } @@ -45957,1909 +47345,6 @@ var ts; } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformES2015Module(context) { - var compilerOptions = context.getCompilerOptions(); - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - return ts.visitEachChild(node, visitor, context); - } - return node; - } - function visitor(node) { - switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - } - return node; - } - function visitExportAssignment(node) { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; - } - } - ts.transformES2015Module = transformES2015Module; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformSystemModule(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration, hoistFunctionDeclaration = context.hoistFunctionDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(188 /* BinaryExpression */); - context.enableSubstitution(186 /* PrefixUnaryExpression */); - context.enableSubstitution(187 /* PostfixUnaryExpression */); - context.enableEmitNotification(256 /* SourceFile */); - var exportFunctionForFileMap = []; - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var hasExportStarsToExportValues; - var exportFunctionForFile; - var contextObjectForFile; - var exportedLocalNames; - var exportedFunctionDeclarations; - var enclosingBlockScopedContainer; - var currentParent; - var currentNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - currentNode = node; - // Perform the transformation. - var updated = transformSystemModuleWorker(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - exportFunctionForFile = undefined; - contextObjectForFile = undefined; - exportedLocalNames = undefined; - exportedFunctionDeclarations = undefined; - return updated; - } - return node; - } - function transformSystemModuleWorker(node) { - // System modules have the following shape: - // - // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) - // - // The parameter 'exports' here is a callback '(name: string, value: T) => T' that - // is used to publish exported values. 'exports' returns its 'value' argument so in - // most cases expressions that mutate exported values can be rewritten as: - // - // expr -> exports('name', expr) - // - // The only exception in this rule is postfix unary operators, - // see comment to 'substitutePostfixUnaryExpression' for more details - ts.Debug.assert(!exportFunctionForFile); - // Collect information about the external module and dependency groups. - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Make sure that the name of the 'exports' function does not conflict with - // existing identifiers. - exportFunctionForFile = ts.createUniqueName("exports"); - contextObjectForFile = ts.createUniqueName("context"); - exportFunctionForFileMap[ts.getOriginalNodeId(node)] = exportFunctionForFile; - var dependencyGroups = collectDependencyGroups(externalImports); - var statements = []; - // Add the body of the module. - addSystemModuleBody(statements, node, dependencyGroups); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, getNameOfDependencyGroup)); - var body = ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter(exportFunctionForFile), - ts.createParameter(contextObjectForFile) - ], - /*type*/ undefined, ts.setEmitFlags(ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true), 1 /* EmitEmitHelpers */)); - // Write the call to `System.register` - // Clear the emit-helpers flag for later passes since we'll have already used it in the module body - // So the helper will be emit at the correct position instead of at the top of the source-file - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), - /*typeArguments*/ undefined, moduleName - ? [moduleName, dependencies, body] - : [dependencies, body])) - ], /*nodeEmitFlags*/ ~1 /* EmitEmitHelpers */ & ts.getEmitFlags(node)); - var _a; - } - /** - * Adds the statements for the module body function for the source file. - * - * @param statements The output statements for the module body. - * @param node The source file for the module. - * @param statementOffset The offset at which to begin visiting the statements of the SourceFile. - */ - function addSystemModuleBody(statements, node, dependencyGroups) { - // Shape of the body in system modules: - // - // function (exports) { - // - // - // - // return { - // setters: [ - // - // ], - // execute: function() { - // - // } - // } - // - // } - // - // i.e: - // - // import {x} from 'file1' - // var y = 1; - // export function foo() { return y + x(); } - // console.log(y); - // - // Will be transformed to: - // - // function(exports) { - // var file_1; // local alias - // var y; - // function foo() { return y + file_1.x(); } - // exports("foo", foo); - // return { - // setters: [ - // function(v) { file_1 = v } - // ], - // execute(): function() { - // y = 1; - // console.log(y); - // } - // }; - // } - // We start a new lexical environment in this function body, but *not* in the - // body of the execute function. This allows us to emit temporary declarations - // only in the outer module body and not in the inner one. - startLexicalEnvironment(); - // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitSourceElement); - // var __moduleName = context_1 && context_1.id; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("__moduleName", - /*type*/ undefined, ts.createLogicalAnd(contextObjectForFile, ts.createPropertyAccess(contextObjectForFile, "id"))) - ]))); - // Visit the statements of the source file, emitting any transformations into - // the `executeStatements` array. We do this *before* we fill the `setters` array - // as we both emit transformations as well as aggregate some data used when creating - // setters. This allows us to reduce the number of times we need to loop through the - // statements of the source file. - var executeStatements = ts.visitNodes(node.statements, visitSourceElement, ts.isStatement, statementOffset); - // We emit the lexical environment (hoisted variables and function declarations) - // early to align roughly with our previous emit output. - // Two key differences in this approach are: - // - Temporary variables will appear at the top rather than at the bottom of the file - // - Calls to the exporter for exported function declarations are grouped after - // the declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Emit early exports for function declarations. - ts.addRange(statements, exportedFunctionDeclarations); - var exportStarFunction = addExportStarIfNeeded(statements); - statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ - ts.createPropertyAssignment("setters", generateSetters(exportStarFunction, dependencyGroups)), - ts.createPropertyAssignment("execute", ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, ts.createBlock(executeStatements, - /*location*/ undefined, - /*multiLine*/ true))) - ]), - /*multiLine*/ true))); - } - function addExportStarIfNeeded(statements) { - if (!hasExportStarsToExportValues) { - return; - } - // when resolving exports local exported entries/indirect exported entries in the module - // should always win over entries with similar names that were added via star exports - // to support this we store names of local/indirect exported entries in a set. - // this set is used to filter names brought by star expors. - // local names set should only be added if we have anything exported - if (!exportedLocalNames && ts.isEmpty(exportSpecifiers)) { - // no exported declarations (export var ...) or export specifiers (export {x}) - // check if we have any non star export declarations. - var hasExportDeclarationWithExportClause = false; - for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) { - var externalImport = externalImports_1[_i]; - if (externalImport.kind === 237 /* ExportDeclaration */ && externalImport.exportClause) { - hasExportDeclarationWithExportClause = true; - break; - } - } - if (!hasExportDeclarationWithExportClause) { - // we still need to emit exportStar helper - return addExportStarFunction(statements, /*localNames*/ undefined); - } - } - var exportedNames = []; - if (exportedLocalNames) { - for (var _a = 0, exportedLocalNames_1 = exportedLocalNames; _a < exportedLocalNames_1.length; _a++) { - var exportedLocalName = exportedLocalNames_1[_a]; - // write name of exported declaration, i.e 'export var x...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName.text), ts.createLiteral(true))); - } - } - for (var _b = 0, externalImports_2 = externalImports; _b < externalImports_2.length; _b++) { - var externalImport = externalImports_2[_b]; - if (externalImport.kind !== 237 /* ExportDeclaration */) { - continue; - } - var exportDecl = externalImport; - if (!exportDecl.exportClause) { - // export * from ... - continue; - } - for (var _c = 0, _d = exportDecl.exportClause.elements; _c < _d.length; _c++) { - var element = _d[_c]; - // write name of indirectly exported entry, i.e. 'export {x} from ...' - exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); - } - } - var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exportedNamesStorageRef, - /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) - ]))); - return addExportStarFunction(statements, exportedNamesStorageRef); - } - /** - * Emits a setter callback for each dependency group. - * @param write The callback used to write each callback. - */ - function generateSetters(exportStarFunction, dependencyGroups) { - var setters = []; - for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group = dependencyGroups_1[_i]; - // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); - var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); - var statements = []; - for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { - var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); - switch (entry.kind) { - case 231 /* ImportDeclaration */: - if (!entry.importClause) { - // 'import "..."' case - // module is imported only for side-effects, no emit required - break; - } - // fall-through - case 230 /* ImportEqualsDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - // save import into the local - statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); - break; - case 237 /* ExportDeclaration */: - ts.Debug.assert(importVariableName !== undefined); - if (entry.exportClause) { - // export {a, b as c} from 'foo' - // - // emit as: - // - // exports_({ - // "a": _["a"], - // "c": _["b"] - // }); - var properties = []; - for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { - var e = _d[_c]; - properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); - } - statements.push(ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); - } - else { - // export * from 'foo' - // - // emit as: - // - // exportStar(foo_1_1); - statements.push(ts.createStatement(ts.createCall(exportStarFunction, - /*typeArguments*/ undefined, [parameterName]))); - } - break; - } - } - setters.push(ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(parameterName)], - /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); - } - return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); - } - function visitSourceElement(node) { - switch (node.kind) { - case 231 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - default: - return visitNestedNode(node); - } - } - function visitNestedNode(node) { - var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; - var savedCurrentParent = currentParent; - var savedCurrentNode = currentNode; - var currentGrandparent = currentParent; - currentParent = currentNode; - currentNode = node; - if (currentParent && ts.isBlockScope(currentParent, currentGrandparent)) { - enclosingBlockScopedContainer = currentParent; - } - var result = visitNestedNodeWorker(node); - enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; - currentParent = savedCurrentParent; - currentNode = savedCurrentNode; - return result; - } - function visitNestedNodeWorker(node) { - switch (node.kind) { - case 201 /* VariableStatement */: - return visitVariableStatement(node); - case 221 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 207 /* ForStatement */: - return visitForStatement(node); - case 208 /* ForInStatement */: - return visitForInStatement(node); - case 209 /* ForOfStatement */: - return visitForOfStatement(node); - case 205 /* DoStatement */: - return visitDoStatement(node); - case 206 /* WhileStatement */: - return visitWhileStatement(node); - case 215 /* LabeledStatement */: - return visitLabeledStatement(node); - case 213 /* WithStatement */: - return visitWithStatement(node); - case 214 /* SwitchStatement */: - return visitSwitchStatement(node); - case 228 /* CaseBlock */: - return visitCaseBlock(node); - case 249 /* CaseClause */: - return visitCaseClause(node); - case 250 /* DefaultClause */: - return visitDefaultClause(node); - case 217 /* TryStatement */: - return visitTryStatement(node); - case 252 /* CatchClause */: - return visitCatchClause(node); - case 200 /* Block */: - return visitBlock(node); - case 203 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - return node; - } - } - function visitImportDeclaration(node) { - if (node.importClause && ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - return undefined; - } - function visitImportEqualsDeclaration(node) { - if (ts.contains(externalImports, node)) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); - } - // NOTE(rbuckton): Do we support export import = require('') in System? - return undefined; - } - function visitExportDeclaration(node) { - if (!node.moduleSpecifier) { - var statements = []; - ts.addRange(statements, ts.map(node.exportClause.elements, visitExportSpecifier)); - return statements; - } - return undefined; - } - function visitExportSpecifier(specifier) { - recordExportName(specifier.name); - return createExportStatement(specifier.name, specifier.propertyName || specifier.name); - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - // Elide `export=` as it is illegal in a SystemJS module. - return undefined; - } - return createExportStatement(ts.createLiteral("default"), node.expression); - } - /** - * Visits a variable statement, hoisting declared names to the top-level module body. - * Each declaration is rewritten into an assignment expression. - * - * @param node The variable statement to visit. - */ - function visitVariableStatement(node) { - // hoist only non-block scoped declarations or block scoped declarations parented by source file - var shouldHoist = ((ts.getCombinedNodeFlags(ts.getOriginalNode(node.declarationList)) & 3 /* BlockScoped */) == 0) || - enclosingBlockScopedContainer.kind === 256 /* SourceFile */; - if (!shouldHoist) { - return node; - } - var isExported = ts.hasModifier(node, 1 /* Export */); - var expressions = []; - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, isExported); - if (visited) { - expressions.push(visited); - } - } - if (expressions.length) { - return ts.createStatement(ts.inlineExpressions(expressions), node); - } - return undefined; - } - /** - * Transforms a VariableDeclaration into one or more assignment expressions. - * - * @param node The VariableDeclaration to transform. - * @param isExported A value used to indicate whether the containing statement was exported. - */ - function transformVariable(node, isExported) { - // Hoist any bound names within the declaration. - hoistBindingElement(node, isExported); - if (!node.initializer) { - // If the variable has no initializer, ignore it. - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - // If the variable has an IdentifierName, write out an assignment expression in its place. - return ts.createAssignment(name, node.initializer); - } - else { - // If the variable has a BindingPattern, flatten the variable into multiple assignment expressions. - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration); - } - } - /** - * Visits a FunctionDeclaration, hoisting it to the outer module body function. - * - * @param node The function declaration to visit. - */ - function visitFunctionDeclaration(node) { - if (ts.hasModifier(node, 1 /* Export */)) { - // If the function is exported, ensure it has a name and rewrite the function without any export flags. - var name_31 = node.name || ts.getGeneratedNameForNode(node); - // Keep async modifier for ES2017 transformer - var isAsync = ts.hasModifier(node, 256 /* Async */); - var newNode = ts.createFunctionDeclaration( - /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name_31, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node); - // Record a declaration export in the outer module body function. - recordExportedFunctionDeclaration(node); - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name_31); - } - ts.setOriginalNode(newNode, node); - node = newNode; - } - // Hoist the function declaration to the outer module body function. - hoistFunctionDeclaration(node); - return undefined; - } - function visitExpressionStatement(node) { - var originalNode = ts.getOriginalNode(node); - if ((originalNode.kind === 226 /* ModuleDeclaration */ || originalNode.kind === 225 /* EnumDeclaration */) && ts.hasModifier(originalNode, 1 /* Export */)) { - var name_32 = getDeclarationName(originalNode); - // We only need to hoistVariableDeclaration for EnumDeclaration - // as ModuleDeclaration is already hoisted when the transformer call visitVariableStatement - // which then call transformsVariable for each declaration in declarationList - if (originalNode.kind === 225 /* EnumDeclaration */) { - hoistVariableDeclaration(name_32); - } - return [ - node, - createExportStatement(name_32, name_32) - ]; - } - return node; - } - /** - * Visits a ClassDeclaration, hoisting its name to the outer module body function. - * - * @param node The class declaration to visit. - */ - function visitClassDeclaration(node) { - // Hoist the name of the class declaration to the outer module body function. - var name = getDeclarationName(node); - hoistVariableDeclaration(name); - var statements = []; - // Rewrite the class declaration into an assignment of a class expression. - statements.push(ts.createStatement(ts.createAssignment(name, ts.createClassExpression( - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node)), - /*location*/ node)); - // If the class was exported, write a declaration export to the inner module body function. - if (ts.hasModifier(node, 1 /* Export */)) { - if (!ts.hasModifier(node, 512 /* Default */)) { - recordExportName(name); - } - statements.push(createDeclarationExport(node)); - } - return statements; - } - function shouldHoistLoopInitializer(node) { - return ts.isVariableDeclarationList(node) && (ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) === 0; - } - /** - * Visits the body of a ForStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var expressions = []; - for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { - var variable = _a[_i]; - var visited = transformVariable(variable, /*isExported*/ false); - if (visited) { - expressions.push(visited); - } - } - ; - return ts.createFor(expressions.length - ? ts.inlineExpressions(expressions) - : ts.createSynthesizedNode(194 /* OmittedExpression */), node.condition, node.incrementor, ts.visitNode(node.statement, visitNestedNode, ts.isStatement), - /*location*/ node); - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Transforms and hoists the declaration list of a ForInStatement or ForOfStatement into an expression. - * - * @param node The decalaration list to transform. - */ - function transformForBinding(node) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); - hoistBindingElement(firstDeclaration, /*isExported*/ false); - var name = firstDeclaration.name; - return ts.isIdentifier(name) - ? name - : ts.flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration); - } - /** - * Visits the body of a ForInStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForInStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a ForOfStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitForOfStatement(node) { - var initializer = node.initializer; - if (shouldHoistLoopInitializer(initializer)) { - var updated = ts.getMutableClone(node); - updated.initializer = transformForBinding(initializer); - updated.statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - return updated; - } - else { - return ts.visitEachChild(node, visitNestedNode, context); - } - } - /** - * Visits the body of a DoStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitDoStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WhileStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWhileStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a LabeledStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitLabeledStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a WithStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitWithStatement(node) { - var statement = ts.visitNode(node.statement, visitNestedNode, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (statement !== node.statement) { - var updated = ts.getMutableClone(node); - updated.statement = statement; - return updated; - } - return node; - } - /** - * Visits the body of a SwitchStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitSwitchStatement(node) { - var caseBlock = ts.visitNode(node.caseBlock, visitNestedNode, ts.isCaseBlock); - if (caseBlock !== node.caseBlock) { - var updated = ts.getMutableClone(node); - updated.caseBlock = caseBlock; - return updated; - } - return node; - } - /** - * Visits the body of a CaseBlock to hoist declarations. - * - * @param node The node to visit. - */ - function visitCaseBlock(node) { - var clauses = ts.visitNodes(node.clauses, visitNestedNode, ts.isCaseOrDefaultClause); - if (clauses !== node.clauses) { - var updated = ts.getMutableClone(node); - updated.clauses = clauses; - return updated; - } - return node; - } - /** - * Visits the body of a CaseClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCaseClause(node) { - var statements = ts.visitNodes(node.statements, visitNestedNode, ts.isStatement); - if (statements !== node.statements) { - var updated = ts.getMutableClone(node); - updated.statements = statements; - return updated; - } - return node; - } - /** - * Visits the body of a DefaultClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitDefaultClause(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a TryStatement to hoist declarations. - * - * @param node The statement to visit. - */ - function visitTryStatement(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - /** - * Visits the body of a CatchClause to hoist declarations. - * - * @param node The clause to visit. - */ - function visitCatchClause(node) { - var block = ts.visitNode(node.block, visitNestedNode, ts.isBlock); - if (block !== node.block) { - var updated = ts.getMutableClone(node); - updated.block = block; - return updated; - } - return node; - } - /** - * Visits the body of a Block to hoist declarations. - * - * @param node The block to visit. - */ - function visitBlock(node) { - return ts.visitEachChild(node, visitNestedNode, context); - } - // - // Substitutions - // - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - exportFunctionForFile = exportFunctionForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - exportFunctionForFile = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - /** - * Substitute the expression, if necessary. - * - * @param node The node to substitute. - */ - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 188 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 186 /* PrefixUnaryExpression */: - case 187 /* PostfixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - /** - * Substitution for identifiers exported at the top level of a module. - */ - function substituteExpressionIdentifier(node) { - var importDeclaration = resolver.getReferencedImportDeclaration(node); - if (importDeclaration) { - var importBinding = createImportBinding(importDeclaration); - if (importBinding) { - return importBinding; - } - } - return node; - } - function substituteBinaryExpression(node) { - if (ts.isAssignmentOperator(node.operatorToken.kind)) { - return substituteAssignmentExpression(node); - } - return node; - } - function substituteAssignmentExpression(node) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var left = node.left; - switch (left.kind) { - case 70 /* Identifier */: - var exportDeclaration = resolver.getReferencedExportContainer(left); - if (exportDeclaration) { - return createExportExpression(left, node); - } - break; - case 172 /* ObjectLiteralExpression */: - case 171 /* ArrayLiteralExpression */: - if (hasExportedReferenceInDestructuringPattern(left)) { - return substituteDestructuring(node); - } - break; - } - return node; - } - function isExportedBinding(name) { - var container = resolver.getReferencedExportContainer(name); - return container && container.kind === 256 /* SourceFile */; - } - function hasExportedReferenceInDestructuringPattern(node) { - switch (node.kind) { - case 70 /* Identifier */: - return isExportedBinding(node); - case 172 /* ObjectLiteralExpression */: - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var property = _a[_i]; - if (hasExportedReferenceInObjectDestructuringElement(property)) { - return true; - } - } - break; - case 171 /* ArrayLiteralExpression */: - for (var _b = 0, _c = node.elements; _b < _c.length; _b++) { - var element = _c[_b]; - if (hasExportedReferenceInArrayDestructuringElement(element)) { - return true; - } - } - break; - } - return false; - } - function hasExportedReferenceInObjectDestructuringElement(node) { - if (ts.isShorthandPropertyAssignment(node)) { - return isExportedBinding(node.name); - } - else if (ts.isPropertyAssignment(node)) { - return hasExportedReferenceInDestructuringElement(node.initializer); - } - else { - return false; - } - } - function hasExportedReferenceInArrayDestructuringElement(node) { - if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else { - return hasExportedReferenceInDestructuringElement(node); - } - } - function hasExportedReferenceInDestructuringElement(node) { - if (ts.isBinaryExpression(node)) { - var left = node.left; - return node.operatorToken.kind === 57 /* EqualsToken */ - && isDestructuringPattern(left) - && hasExportedReferenceInDestructuringPattern(left); - } - else if (ts.isIdentifier(node)) { - return isExportedBinding(node); - } - else if (ts.isSpreadElementExpression(node)) { - var expression = node.expression; - return ts.isIdentifier(expression) && isExportedBinding(expression); - } - else if (isDestructuringPattern(node)) { - return hasExportedReferenceInDestructuringPattern(node); - } - else { - return false; - } - } - function isDestructuringPattern(node) { - var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 172 /* ObjectLiteralExpression */ - || kind === 171 /* ArrayLiteralExpression */; - } - function substituteDestructuring(node) { - return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration); - } - function substituteUnaryExpression(node) { - var operand = node.operand; - var operator = node.operator; - var substitute = ts.isIdentifier(operand) && - (node.kind === 187 /* PostfixUnaryExpression */ || - (node.kind === 186 /* PrefixUnaryExpression */ && (operator === 42 /* PlusPlusToken */ || operator === 43 /* MinusMinusToken */))); - if (substitute) { - var exportDeclaration = resolver.getReferencedExportContainer(operand); - if (exportDeclaration) { - var expr = ts.createPrefix(node.operator, operand, node); - ts.setEmitFlags(expr, 128 /* NoSubstitution */); - var call = createExportExpression(operand, expr); - if (node.kind === 186 /* PrefixUnaryExpression */) { - return call; - } - else { - // export function returns the value that was passes as the second argument - // however for postfix unary expressions result value should be the value before modification. - // emit 'x++' as '(export('x', ++x) - 1)' and 'x--' as '(export('x', --x) + 1)' - return operator === 42 /* PlusPlusToken */ - ? ts.createSubtract(call, ts.createLiteral(1)) - : ts.createAdd(call, ts.createLiteral(1)); - } - } - } - return node; - } - /** - * Gets a name to use for a DeclarationStatement. - * @param node The declaration statement. - */ - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function addExportStarFunction(statements, localNames) { - var exportStarFunction = ts.createUniqueName("exportStar"); - var m = ts.createIdentifier("m"); - var n = ts.createIdentifier("n"); - var exports = ts.createIdentifier("exports"); - var condition = ts.createStrictInequality(n, ts.createLiteral("default")); - if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); - } - statements.push(ts.createFunctionDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, exportStarFunction, - /*typeParameters*/ undefined, [ts.createParameter(m)], - /*type*/ undefined, ts.createBlock([ - ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(exports, - /*type*/ undefined, ts.createObjectLiteral([])) - ])), - ts.createForIn(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(n, /*type*/ undefined) - ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) - ])), - ts.createStatement(ts.createCall(exportFunctionForFile, - /*typeArguments*/ undefined, [exports])) - ], - /*location*/ undefined, - /*multiline*/ true))); - return exportStarFunction; - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportExpression(name, value) { - var exportName = ts.isIdentifier(name) ? ts.createLiteral(name.text) : name; - return ts.createCall(exportFunctionForFile, /*typeArguments*/ undefined, [exportName, value]); - } - /** - * Creates a call to the current file's export function to export a value. - * @param name The bound name of the export. - * @param value The exported value. - */ - function createExportStatement(name, value) { - return ts.createStatement(createExportExpression(name, value)); - } - /** - * Creates a call to the current file's export function to export a declaration. - * @param node The declaration to export. - */ - function createDeclarationExport(node) { - var declarationName = getDeclarationName(node); - var exportName = ts.hasModifier(node, 512 /* Default */) ? ts.createLiteral("default") : declarationName; - return createExportStatement(exportName, declarationName); - } - function createImportBinding(importDeclaration) { - var importAlias; - var name; - if (ts.isImportClause(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent); - name = ts.createIdentifier("default"); - } - else if (ts.isImportSpecifier(importDeclaration)) { - importAlias = ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent); - name = importDeclaration.propertyName || importDeclaration.name; - } - else { - return undefined; - } - return ts.createPropertyAccess(importAlias, ts.getSynthesizedClone(name)); - } - function collectDependencyGroups(externalImports) { - var groupIndices = ts.createMap(); - var dependencyGroups = []; - for (var i = 0; i < externalImports.length; i++) { - var externalImport = externalImports[i]; - var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - if (ts.hasProperty(groupIndices, text)) { - // deduplicate/group entries in dependency list by the dependency name - var groupIndex = groupIndices[text]; - dependencyGroups[groupIndex].externalImports.push(externalImport); - continue; - } - else { - groupIndices[text] = dependencyGroups.length; - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); - } - } - return dependencyGroups; - } - function getNameOfDependencyGroup(dependencyGroup) { - return dependencyGroup.name; - } - function recordExportName(name) { - if (!exportedLocalNames) { - exportedLocalNames = []; - } - exportedLocalNames.push(name); - } - function recordExportedFunctionDeclaration(node) { - if (!exportedFunctionDeclarations) { - exportedFunctionDeclarations = []; - } - exportedFunctionDeclarations.push(createDeclarationExport(node)); - } - function hoistBindingElement(node, isExported) { - if (ts.isOmittedExpression(node)) { - return; - } - var name = node.name; - if (ts.isIdentifier(name)) { - hoistVariableDeclaration(ts.getSynthesizedClone(name)); - if (isExported) { - recordExportName(name); - } - } - else if (ts.isBindingPattern(name)) { - ts.forEach(name.elements, isExported ? hoistExportedBindingElement : hoistNonExportedBindingElement); - } - } - function hoistExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ true); - } - function hoistNonExportedBindingElement(node) { - hoistBindingElement(node, /*isExported*/ false); - } - function updateSourceFile(node, statements, nodeEmitFlags) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - ts.setEmitFlags(updated, nodeEmitFlags); - return updated; - } - } - ts.transformSystemModule = transformSystemModule; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; -(function (ts) { - function transformModule(context) { - var transformModuleDelegates = ts.createMap((_a = {}, - _a[ts.ModuleKind.None] = transformCommonJSModule, - _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, - _a[ts.ModuleKind.AMD] = transformAMDModule, - _a[ts.ModuleKind.UMD] = transformUMDModule, - _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; - var compilerOptions = context.getCompilerOptions(); - var resolver = context.getEmitResolver(); - var host = context.getEmitHost(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var moduleKind = ts.getEmitModuleKind(compilerOptions); - var previousOnSubstituteNode = context.onSubstituteNode; - var previousOnEmitNode = context.onEmitNode; - context.onSubstituteNode = onSubstituteNode; - context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(188 /* BinaryExpression */); - context.enableSubstitution(186 /* PrefixUnaryExpression */); - context.enableSubstitution(187 /* PostfixUnaryExpression */); - context.enableSubstitution(254 /* ShorthandPropertyAssignment */); - context.enableEmitNotification(256 /* SourceFile */); - var currentSourceFile; - var externalImports; - var exportSpecifiers; - var exportEquals; - var bindingNameExportSpecifiersMap; - // Subset of exportSpecifiers that is a binding-name. - // This is to reduce amount of memory we have to keep around even after we done with module-transformer - var bindingNameExportSpecifiersForFileMap = ts.createMap(); - var hasExportStarsToExportValues; - return transformSourceFile; - /** - * Transforms the module aspects of a SourceFile. - * - * @param node The SourceFile node. - */ - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; - // Collect information about the external module. - (_a = ts.collectExternalModuleInfo(node), externalImports = _a.externalImports, exportSpecifiers = _a.exportSpecifiers, exportEquals = _a.exportEquals, hasExportStarsToExportValues = _a.hasExportStarsToExportValues, _a); - // Perform the transformation. - var transformModule_1 = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; - var updated = transformModule_1(node); - ts.aggregateTransformFlags(updated); - currentSourceFile = undefined; - externalImports = undefined; - exportSpecifiers = undefined; - exportEquals = undefined; - hasExportStarsToExportValues = false; - return updated; - } - return node; - var _a; - } - /** - * Transforms a SourceFile into a CommonJS module. - * - * @param node The SourceFile node. - */ - function transformCommonJSModule(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - var updated = updateSourceFile(node, statements); - if (hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); - } - return updated; - } - /** - * Transforms a SourceFile into an AMD module. - * - * @param node The SourceFile node. - */ - function transformAMDModule(node) { - var define = ts.createIdentifier("define"); - var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); - return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); - } - /** - * Transforms a SourceFile into a UMD module. - * - * @param node The SourceFile node. - */ - function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16 /* UMDDefine */); - return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); - } - /** - * Transforms a SourceFile into an AMD or UMD module. - * - * @param node The SourceFile node. - * @param define The expression used to define the module. - * @param moduleName An expression for the module name, if available. - * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. - */ - function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { - // An AMD define function has the following shape: - // - // define(id?, dependencies?, factory); - // - // This has the shape of the following: - // - // define(name, ["module1", "module2"], function (module1Alias) { ... } - // - // The location of the alias in the parameter list in the factory function needs to - // match the position of the module name in the dependency list. - // - // To ensure this is true in cases of modules with no aliases, e.g.: - // - // import "module" - // - // or - // - // /// - // - // we need to add modules without alias names to the end of the dependencies list - var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; - // Create an updated SourceFile: - // - // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFile(node, [ - ts.createStatement(ts.createCall(define, - /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ - // Add the dependency array argument: - // - // ["require", "exports", module1", "module2", ...] - ts.createArrayLiteral([ - ts.createLiteral("require"), - ts.createLiteral("exports") - ].concat(aliasedModuleNames, unaliasedModuleNames)), - // Add the module body function argument: - // - // function (require, exports, module1, module2) ... - ts.createFunctionExpression( - /*modifiers*/ undefined, - /*asteriskToken*/ undefined, - /*name*/ undefined, - /*typeParameters*/ undefined, [ - ts.createParameter("require"), - ts.createParameter("exports") - ].concat(importAliasNames), - /*type*/ undefined, transformAsynchronousModuleBody(node)) - ]))) - ]); - } - /** - * Transforms a SourceFile into an AMD or UMD module body. - * - * @param node The SourceFile node. - */ - function transformAsynchronousModuleBody(node) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, visitor); - // Visit each statement of the module body. - ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); - // End the lexical environment for the module body - // and merge any new lexical declarations. - ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); - var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); - if (hasExportStarsToExportValues) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.setEmitFlags(body, 2 /* EmitExportStar */); - } - return body; - } - function addExportEqualsIfNeeded(statements, emitAsReturn) { - if (exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(exportEquals.expression, - /*location*/ exportEquals); - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), exportEquals.expression), - /*location*/ exportEquals); - ts.setEmitFlags(statement, 49152 /* NoComments */); - statements.push(statement); - } - } - } - /** - * Visits a node at the top level of the source file. - * - * @param node The node. - */ - function visitor(node) { - switch (node.kind) { - case 231 /* ImportDeclaration */: - return visitImportDeclaration(node); - case 230 /* ImportEqualsDeclaration */: - return visitImportEqualsDeclaration(node); - case 237 /* ExportDeclaration */: - return visitExportDeclaration(node); - case 236 /* ExportAssignment */: - return visitExportAssignment(node); - case 201 /* VariableStatement */: - return visitVariableStatement(node); - case 221 /* FunctionDeclaration */: - return visitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: - return visitClassDeclaration(node); - case 203 /* ExpressionStatement */: - return visitExpressionStatement(node); - default: - // This visitor does not descend into the tree, as export/import statements - // are only transformed at the top level of a file. - return node; - } - } - /** - * Visits an ImportDeclaration node. - * - * @param node The ImportDeclaration node. - */ - function visitImportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var statements = []; - var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); - if (moduleKind !== ts.ModuleKind.AMD) { - if (!node.importClause) { - // import "mod"; - statements.push(ts.createStatement(createRequireCall(node), - /*location*/ node)); - } - else { - var variables = []; - if (namespaceDeclaration && !ts.isDefaultImport(node)) { - // import * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, createRequireCall(node))); - } - else { - // import d from "mod"; - // import { x, y } from "mod"; - // import d, { x, y } from "mod"; - // import d, * as n from "mod"; - variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), - /*type*/ undefined, createRequireCall(node))); - if (namespaceDeclaration && ts.isDefaultImport(node)) { - variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node))); - } - } - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createConstDeclarationList(variables), - /*location*/ node)); - } - } - else if (namespaceDeclaration && ts.isDefaultImport(node)) { - // import d, * as n from "mod"; - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), - /*type*/ undefined, ts.getGeneratedNameForNode(node), - /*location*/ node) - ]))); - } - addExportImportAssignments(statements, node); - return ts.singleOrMany(statements); - } - function visitImportEqualsDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - // Set emitFlags on the name of the importEqualsDeclaration - // This is so the printer will not substitute the identifier - ts.setEmitFlags(node.name, 128 /* NoSubstitution */); - var statements = []; - if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, createRequireCall(node)), - /*location*/ node)); - } - else { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), - /*type*/ undefined, createRequireCall(node)) - ], - /*location*/ undefined, - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), - /*location*/ node)); - } - } - else { - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.createStatement(createExportAssignment(node.name, node.name), - /*location*/ node)); - } - } - addExportImportAssignments(statements, node); - return statements; - } - function visitExportDeclaration(node) { - if (!ts.contains(externalImports, node)) { - return undefined; - } - var generatedName = ts.getGeneratedNameForNode(node); - if (node.exportClause) { - var statements = []; - // export { x, y } from "mod"; - if (moduleKind !== ts.ModuleKind.AMD) { - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(generatedName, - /*type*/ undefined, createRequireCall(node)) - ]), - /*location*/ node)); - } - for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { - var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.createStatement(createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier)); - } - return ts.singleOrMany(statements); - } - else { - // export * from "mod"; - return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), - /*typeArguments*/ undefined, [ - moduleKind !== ts.ModuleKind.AMD - ? createRequireCall(node) - : generatedName - ]), - /*location*/ node); - } - } - function visitExportAssignment(node) { - if (node.isExportEquals) { - // Elide as `export=` is handled in addExportEqualsIfNeeded - return undefined; - } - var statements = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } - function addExportDefault(statements, expression, location) { - tryAddExportDefaultCompat(statements); - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("default"), expression), location)); - } - function tryAddExportDefaultCompat(statements) { - var original = ts.getOriginalNode(currentSourceFile); - ts.Debug.assert(original.kind === 256 /* SourceFile */); - if (!original.symbol.exports["___esModule"]) { - if (languageVersion === 0 /* ES3 */) { - statements.push(ts.createStatement(createExportAssignment(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); - } - else { - statements.push(ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), - /*typeArguments*/ undefined, [ - ts.createIdentifier("exports"), - ts.createLiteral("__esModule"), - ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) - ]) - ]))); - } - } - } - function addExportImportAssignments(statements, node) { - if (ts.isImportEqualsDeclaration(node)) { - addExportMemberAssignments(statements, node.name); - } - else { - var names = ts.reduceEachChild(node, collectExportMembers, []); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_33 = names_1[_i]; - addExportMemberAssignments(statements, name_33); - } - } - } - function collectExportMembers(names, node) { - if (ts.isAliasSymbolDeclaration(node) && ts.isDeclaration(node)) { - var name_34 = node.name; - if (ts.isIdentifier(name_34)) { - names.push(name_34); - } - } - return ts.reduceEachChild(node, collectExportMembers, names); - } - function addExportMemberAssignments(statements, name) { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - for (var _i = 0, _a = exportSpecifiers[name.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - statements.push(ts.startOnNewLine(ts.createStatement(createExportAssignment(specifier.name, name), - /*location*/ specifier.name))); - } - } - } - function addExportMemberAssignment(statements, node) { - if (ts.hasModifier(node, 512 /* Default */)) { - addExportDefault(statements, getDeclarationName(node), /*location*/ node); - } - else { - statements.push(createExportStatement(node.name, ts.setEmitFlags(ts.getSynthesizedClone(node.name), 262144 /* LocalName */), /*location*/ node)); - } - } - function visitVariableStatement(node) { - // If the variable is for a generated declaration, - // we should maintain it and just strip off the 'export' modifier if necessary. - var originalKind = ts.getOriginalNode(node).kind; - if (originalKind === 226 /* ModuleDeclaration */ || - originalKind === 225 /* EnumDeclaration */ || - originalKind === 222 /* ClassDeclaration */) { - if (!ts.hasModifier(node, 1 /* Export */)) { - return node; - } - return ts.setOriginalNode(ts.createVariableStatement( - /*modifiers*/ undefined, node.declarationList), node); - } - var resultStatements = []; - // If we're exporting these variables, then these just become assignments to 'exports.blah'. - // We only want to emit assignments for variables with initializers. - if (ts.hasModifier(node, 1 /* Export */)) { - var variables = ts.getInitializedVariables(node.declarationList); - if (variables.length > 0) { - var inlineAssignments = ts.createStatement(ts.inlineExpressions(ts.map(variables, transformInitializedVariable)), node); - resultStatements.push(inlineAssignments); - } - } - else { - resultStatements.push(node); - } - // While we might not have been exported here, each variable might have been exported - // later on in an export specifier (e.g. `export {foo as blah, bar}`). - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - addExportMemberAssignmentsForBindingName(resultStatements, decl.name); - } - return resultStatements; - } - /** - * Creates appropriate assignments for each binding identifier that is exported in an export specifier, - * and inserts it into 'resultStatements'. - */ - function addExportMemberAssignmentsForBindingName(resultStatements, name) { - if (ts.isBindingPattern(name)) { - for (var _i = 0, _a = name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!ts.isOmittedExpression(element)) { - addExportMemberAssignmentsForBindingName(resultStatements, element.name); - } - } - } - else { - if (!exportEquals && exportSpecifiers && ts.hasProperty(exportSpecifiers, name.text)) { - var sourceFileId = ts.getOriginalNodeId(currentSourceFile); - if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = ts.createMap(); - } - bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; - addExportMemberAssignments(resultStatements, name); - } - } - } - function transformInitializedVariable(node) { - var name = node.name; - if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, getModuleMemberName, visitor); - } - else { - return ts.createAssignment(getModuleMemberName(name), ts.visitNode(node.initializer, visitor, ts.isExpression)); - } - } - function visitFunctionDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - // Keep async modifier for ES2017 transformer - var isAsync = ts.hasModifier(node, 256 /* Async */); - statements.push(ts.setOriginalNode(ts.createFunctionDeclaration( - /*decorators*/ undefined, isAsync ? [ts.createNode(119 /* AsyncKeyword */)] : undefined, node.asteriskToken, name, - /*typeParameters*/ undefined, node.parameters, - /*type*/ undefined, node.body, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - if (node.name) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitClassDeclaration(node) { - var statements = []; - var name = node.name || ts.getGeneratedNameForNode(node); - if (ts.hasModifier(node, 1 /* Export */)) { - statements.push(ts.setOriginalNode(ts.createClassDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, name, - /*typeParameters*/ undefined, node.heritageClauses, node.members, - /*location*/ node), - /*original*/ node)); - addExportMemberAssignment(statements, node); - } - else { - statements.push(node); - } - // Decorators end up creating a series of assignment expressions which overwrite - // the local binding that we export, so we need to defer from exporting decorated classes - // until the decoration assignments take place. We do this when visiting expression-statements. - if (node.name && !(node.decorators && node.decorators.length)) { - addExportMemberAssignments(statements, node.name); - } - return ts.singleOrMany(statements); - } - function visitExpressionStatement(node) { - var original = ts.getOriginalNode(node); - var origKind = original.kind; - if (origKind === 225 /* EnumDeclaration */ || origKind === 226 /* ModuleDeclaration */) { - return visitExpressionStatementForEnumOrNamespaceDeclaration(node, original); - } - else if (origKind === 222 /* ClassDeclaration */) { - // The decorated assignment for a class name may need to be transformed. - var classDecl = original; - if (classDecl.name) { - var statements = [node]; - addExportMemberAssignments(statements, classDecl.name); - return statements; - } - } - return node; - } - function visitExpressionStatementForEnumOrNamespaceDeclaration(node, original) { - var statements = [node]; - // Preserve old behavior for enums in which a variable statement is emitted after the body itself. - if (ts.hasModifier(original, 1 /* Export */) && - original.kind === 225 /* EnumDeclaration */ && - ts.isFirstDeclarationOfKind(original, 225 /* EnumDeclaration */)) { - addVarForExportedEnumOrNamespaceDeclaration(statements, original); - } - addExportMemberAssignments(statements, original.name); - return statements; - } - /** - * Adds a trailing VariableStatement for an enum or module declaration. - */ - function addVarForExportedEnumOrNamespaceDeclaration(statements, node) { - var transformedStatement = ts.createVariableStatement( - /*modifiers*/ undefined, [ts.createVariableDeclaration(getDeclarationName(node), - /*type*/ undefined, ts.createPropertyAccess(ts.createIdentifier("exports"), getDeclarationName(node)))], - /*location*/ node); - ts.setEmitFlags(transformedStatement, 49152 /* NoComments */); - statements.push(transformedStatement); - } - function getDeclarationName(node) { - return node.name ? ts.getSynthesizedClone(node.name) : ts.getGeneratedNameForNode(node); - } - function onEmitNode(emitContext, node, emitCallback) { - if (node.kind === 256 /* SourceFile */) { - bindingNameExportSpecifiersMap = bindingNameExportSpecifiersForFileMap[ts.getOriginalNodeId(node)]; - previousOnEmitNode(emitContext, node, emitCallback); - bindingNameExportSpecifiersMap = undefined; - } - else { - previousOnEmitNode(emitContext, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. - */ - function onSubstituteNode(emitContext, node) { - node = previousOnSubstituteNode(emitContext, node); - if (emitContext === 1 /* Expression */) { - return substituteExpression(node); - } - else if (ts.isShorthandPropertyAssignment(node)) { - return substituteShorthandPropertyAssignment(node); - } - return node; - } - function substituteShorthandPropertyAssignment(node) { - var name = node.name; - var exportedOrImportedName = substituteExpressionIdentifier(name); - if (exportedOrImportedName !== name) { - // A shorthand property with an assignment initializer is probably part of a - // destructuring assignment - if (node.objectAssignmentInitializer) { - var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name, initializer, /*location*/ node); - } - return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); - } - return node; - } - function substituteExpression(node) { - switch (node.kind) { - case 70 /* Identifier */: - return substituteExpressionIdentifier(node); - case 188 /* BinaryExpression */: - return substituteBinaryExpression(node); - case 187 /* PostfixUnaryExpression */: - case 186 /* PrefixUnaryExpression */: - return substituteUnaryExpression(node); - } - return node; - } - function substituteExpressionIdentifier(node) { - return trySubstituteExportedName(node) - || trySubstituteImportedName(node) - || node; - } - function substituteBinaryExpression(node) { - var left = node.left; - // If the left-hand-side of the binaryExpression is an identifier and its is export through export Specifier - if (ts.isIdentifier(left) && ts.isAssignmentOperator(node.operatorToken.kind)) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, left.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[left.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, node); - } - return nestedExportAssignment; - } - } - return node; - } - function substituteUnaryExpression(node) { - // Because how the compiler only parse plusplus and minusminus to be either prefixUnaryExpression or postFixUnaryExpression depended on where they are - // We don't need to check that the operator has SyntaxKind.plusplus or SyntaxKind.minusminus - var operator = node.operator; - var operand = node.operand; - if (ts.isIdentifier(operand) && bindingNameExportSpecifiersForFileMap) { - if (bindingNameExportSpecifiersMap && ts.hasProperty(bindingNameExportSpecifiersMap, operand.text)) { - ts.setEmitFlags(node, 128 /* NoSubstitution */); - var transformedUnaryExpression = void 0; - if (node.kind === 187 /* PostfixUnaryExpression */) { - transformedUnaryExpression = ts.createBinary(operand, ts.createToken(operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), - /*location*/ node); - // We have to set no substitution flag here to prevent visit the binary expression and substitute it again as we will preform all necessary substitution in here - ts.setEmitFlags(transformedUnaryExpression, 128 /* NoSubstitution */); - } - var nestedExportAssignment = void 0; - for (var _i = 0, _a = bindingNameExportSpecifiersMap[operand.text]; _i < _a.length; _i++) { - var specifier = _a[_i]; - nestedExportAssignment = nestedExportAssignment ? - createExportAssignment(specifier.name, nestedExportAssignment) : - createExportAssignment(specifier.name, transformedUnaryExpression || node); - } - return nestedExportAssignment; - } - } - return node; - } - function trySubstituteExportedName(node) { - var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 262144 /* LocalName */) === 0) { - var container = resolver.getReferencedExportContainer(node, (emitFlags & 131072 /* ExportName */) !== 0); - if (container) { - if (container.kind === 256 /* SourceFile */) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), - /*location*/ node); - } - } - } - return undefined; - } - function trySubstituteImportedName(node) { - if ((ts.getEmitFlags(node) & 262144 /* LocalName */) === 0) { - var declaration = resolver.getReferencedImportDeclaration(node); - if (declaration) { - if (ts.isImportClause(declaration)) { - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent), ts.createIdentifier("default"), - /*location*/ node); - } - else if (ts.isImportSpecifier(declaration)) { - var name_35 = declaration.propertyName || declaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(declaration.parent.parent.parent), ts.getSynthesizedClone(name_35), - /*location*/ node); - } - } - } - return undefined; - } - function getModuleMemberName(name) { - return ts.createPropertyAccess(ts.createIdentifier("exports"), name, - /*location*/ name); - } - function createRequireCall(importNode) { - var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - var args = []; - if (ts.isDefined(moduleName)) { - args.push(moduleName); - } - return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); - } - function createExportStatement(name, value, location) { - var statement = ts.createStatement(createExportAssignment(name, value)); - statement.startsOnNewLine = true; - if (location) { - ts.setSourceMapRange(statement, location); - } - return statement; - } - function createExportAssignment(name, value) { - return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value); - } - function collectAsynchronousDependencies(node, includeNonAmdDependencies) { - // names of modules with corresponding parameter in the factory function - var aliasedModuleNames = []; - // names of modules with no corresponding parameters in factory function - var unaliasedModuleNames = []; - // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding - // module names in aliasedModuleNames. - var importAliasNames = []; - // Fill in amd-dependency tags - for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { - var amdDependency = _a[_i]; - if (amdDependency.name) { - aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - importAliasNames.push(ts.createParameter(amdDependency.name)); - } - else { - unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); - } - } - for (var _b = 0, externalImports_3 = externalImports; _b < externalImports_3.length; _b++) { - var importNode = externalImports_3[_b]; - // Find the name of the external module - var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); - // Find the name of the module alias, if there is one - var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); - } - } - return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; - } - function updateSourceFile(node, statements) { - var updated = ts.getMutableClone(node); - updated.statements = ts.createNodeArray(statements, node.statements); - return updated; - } - var _a; - } - ts.transformModule = transformModule; -})(ts || (ts = {})); /// /// /*@internal*/ @@ -47897,11 +47382,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitJsxExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -47912,11 +47397,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return visitJsxExpression(node); - case 242 /* JsxElement */: + case 245 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -47953,7 +47438,7 @@ var ts; objectProperties = ts.singleOrUndefined(segments) || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); } - var element = ts.createReactCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -47975,7 +47460,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.createLiteral(decoded, /*location*/ node) : node; } - else if (node.kind === 248 /* JsxExpression */) { + else if (node.kind === 251 /* JsxExpression */) { return visitJsxExpression(node); } else { @@ -48057,16 +47542,16 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 242 /* JsxElement */) { + if (node.kind === 245 /* JsxElement */) { return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_34 = node.tagName; + if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { + return ts.createLiteral(name_34.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_34); } } } @@ -48351,6 +47836,232 @@ var ts; /// /*@internal*/ var ts; +(function (ts) { + function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; + var currentSourceFile; + return transformSourceFile; + function transformSourceFile(node) { + currentSourceFile = node; + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if (node.transformFlags & 16 /* ESNext */) { + return visitorWorker(node); + } + else if (node.transformFlags & 32 /* ContainsESNext */) { + return ts.visitEachChild(node, visitor, context); + } + else { + return node; + } + } + function visitorWorker(node) { + switch (node.kind) { + case 175 /* ObjectLiteralExpression */: + return visitObjectLiteralExpression(node); + case 191 /* BinaryExpression */: + return visitBinaryExpression(node); + case 222 /* VariableDeclaration */: + return visitVariableDeclaration(node); + case 212 /* ForOfStatement */: + return visitForOfStatement(node); + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: + return node; + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 183 /* FunctionExpression */: + return visitFunctionExpression(node); + case 184 /* ArrowFunction */: + return visitArrowFunction(node); + case 144 /* Parameter */: + return visitParameter(node); + default: + ts.Debug.failBadSyntaxKind(node); + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 258 /* SpreadAssignment */) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 256 /* PropertyAssignment */) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + // spread elements emit like so: + // non-spread elements are chunked together into object literals, and then all are passed to __assign: + // { a, ...o, b } => __assign({a}, o, {b}); + // If the first element is a spread element, then the first argument to __assign is {}: + // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 175 /* ObjectLiteralExpression */) { + objects.unshift(ts.createObjectLiteral()); + } + return ts.createCall(ts.createIdentifier("__assign"), undefined, objects); + } + /** + * Visits a BinaryExpression that contains a destructuring assignment. + * + * @param node A BinaryExpression node. + */ + function visitBinaryExpression(node) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48 /* AssertESNext */) { + return ts.flattenDestructuringAssignment(context, node, /*needsDestructuringValue*/ true, hoistVariableDeclaration, visitor, /*transformRest*/ true); + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a VariableDeclaration node with a binding pattern. + * + * @param node A VariableDeclaration node. + */ + function visitVariableDeclaration(node) { + // If we are here it is because the name contains a binding pattern with a rest somewhere in it. + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48 /* AssertESNext */) { + var result = ts.flattenVariableDestructuring(node, /*value*/ undefined, visitor, /*recordTempVariable*/ undefined, /*transformRest*/ true); + return result; + } + return ts.visitEachChild(node, visitor, context); + } + /** + * Visits a ForOfStatement and converts it into a ES2015-compatible ForOfStatement. + * + * @param node A ForOfStatement. + */ + function visitForOfStatement(node) { + // The following ESNext code: + // + // for (let { x, y, ...rest } of expr) { } + // + // should be emitted as + // + // for (var _a of expr) { + // let { x, y } = _a, rest = __rest(_a, ["x", "y"]); + // } + // + // where _a is a temp emitted to capture the RHS. + // When the left hand side is an expression instead of a let declaration, + // the `let` before the `{ x, y }` is not emitted. + // When the left hand side is a let/const, the v is renamed if there is + // another v in scope. + // Note that all assignments to the LHS are emitted in the body, including + // all destructuring. + // Note also that because an extra statement is needed to assign to the LHS, + // for-of bodies are always emitted as blocks. + // for ( of ) + // where is [let] variabledeclarationlist | expression + var initializer = node.initializer; + if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { + return ts.visitEachChild(node, visitor, context); + } + return ts.convertForOf(node, undefined, visitor, ts.noop, context, /*transformRest*/ true); + } + function isRestBindingPattern(initializer) { + if (ts.isVariableDeclarationList(initializer)) { + var declaration = ts.firstOrUndefined(initializer.declarations); + return declaration && declaration.name && + declaration.name.kind === 171 /* ObjectBindingPattern */ && + !!(declaration.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + return false; + } + function isRestAssignment(initializer) { + return initializer.kind === 175 /* ObjectLiteralExpression */ && + initializer.transformFlags & 8388608 /* ContainsSpreadExpression */; + } + function visitParameter(node) { + if (isObjectRestParameter(node)) { + // Binding patterns are converted into a generated name and are + // evaluated inside the function body. + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, + /*type*/ undefined, node.initializer, + /*location*/ node), + /*original*/ node); + } + else { + return node; + } + } + function isObjectRestParameter(node) { + return node.name && + node.name.kind === 171 /* ObjectBindingPattern */ && + !!(node.name.transformFlags & 8388608 /* ContainsSpreadExpression */); + } + function visitFunctionDeclaration(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, body, + /*location*/ node), + /*original*/ node); + } + function visitArrowFunction(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + var func = ts.setOriginalNode(ts.createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, node.equalsGreaterThanToken, body, + /*location*/ node), + /*original*/ node); + ts.setEmitFlags(func, 256 /* CapturesThis */); + return func; + } + function visitFunctionExpression(node) { + var hasRest = ts.forEach(node.parameters, isObjectRestParameter); + var body = hasRest ? + ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, /*convertObjectRest*/ true) : + ts.visitEachChild(node.body, visitor, context); + return ts.setOriginalNode(ts.createFunctionExpression( + /*modifiers*/ undefined, node.asteriskToken, name, + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), + /*type*/ undefined, body, + /*location*/ node), + /*original*/ node); + } + } + ts.transformESNext = transformESNext; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; (function (ts) { function transformES2017(context) { var ES2017SubstitutionFlags; @@ -48395,10 +48106,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 16 /* ES2017 */) { + if (node.transformFlags & 64 /* ES2017 */) { return visitorWorker(node); } - else if (node.transformFlags & 32 /* ContainsES2017 */) { + else if (node.transformFlags & 128 /* ContainsES2017 */) { return ts.visitEachChild(node, visitor, context); } return node; @@ -48408,19 +48119,19 @@ var ts; case 119 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: // ES2017 'await' expressions must be transformed for targets < ES2017. return visitAwaitExpression(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: // ES2017 method declarations may be 'async' return visitMethodDeclaration(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: // ES2017 function declarations may be 'async' return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: // ES2017 function expressions may be 'async' return visitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: // ES2017 arrow functions may be 'async' return visitArrowFunction(node); default: @@ -48541,9 +48252,10 @@ var ts; return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); } function transformAsyncFunctionBody(node) { - var nodeType = node.original ? node.original.type : node.type; + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 181 /* ArrowFunction */; + var isArrowFunction = node.kind === 184 /* 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 @@ -48593,12 +48305,14 @@ var ts; } } function getPromiseConstructor(type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; + if (type) { + var typeName = ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } } } return undefined; @@ -48608,24 +48322,24 @@ 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(175 /* CallExpression */); - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(174 /* ElementAccessExpression */); + context.enableSubstitution(178 /* CallExpression */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(177 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(222 /* ClassDeclaration */); - context.enableEmitNotification(148 /* MethodDeclaration */); - context.enableEmitNotification(150 /* GetAccessor */); - context.enableEmitNotification(151 /* SetAccessor */); - context.enableEmitNotification(149 /* Constructor */); + context.enableEmitNotification(225 /* ClassDeclaration */); + context.enableEmitNotification(149 /* MethodDeclaration */); + context.enableEmitNotification(151 /* GetAccessor */); + context.enableEmitNotification(152 /* SetAccessor */); + context.enableEmitNotification(150 /* Constructor */); } } function substituteExpression(node) { switch (node.kind) { - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { return substituteCallExpression(node); } @@ -48669,11 +48383,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 222 /* ClassDeclaration */ - || kind === 149 /* Constructor */ - || kind === 148 /* MethodDeclaration */ - || kind === 150 /* GetAccessor */ - || kind === 151 /* SetAccessor */; + return kind === 225 /* ClassDeclaration */ + || kind === 150 /* Constructor */ + || kind === 149 /* MethodDeclaration */ + || kind === 151 /* GetAccessor */ + || kind === 152 /* SetAccessor */; } /** * Hook for node emit. @@ -48739,10 +48453,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 64 /* ES2016 */) { + if (node.transformFlags & 256 /* ES2016 */) { return visitorWorker(node); } - else if (node.transformFlags & 128 /* ContainsES2016 */) { + else if (node.transformFlags & 512 /* ContainsES2016 */) { return ts.visitEachChild(node, visitor, context); } else { @@ -48751,7 +48465,7 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -48927,11 +48641,11 @@ var ts; return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return isInConstructorWithCapturedSuper && node.kind === 212 /* ReturnStatement */ && !node.expression; + return isInConstructorWithCapturedSuper && node.kind === 215 /* ReturnStatement */ && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 256 /* ES2015 */) !== 0 || - node.kind === 215 /* LabeledStatement */ || + return (node.transformFlags & 1024 /* ES2015 */) !== 0 || + node.kind === 218 /* LabeledStatement */ || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)); } function visitorWorker(node) { @@ -48941,7 +48655,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 512 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 2048 /* ContainsES2015 */ || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { // we want to dive in this branch either if node has children with ES2015 specific syntax // or we are inside constructor that captures result of the super call so all returns without expression should be // rewritten. Note: we skip expressions since returns should never appear there @@ -48963,15 +48677,15 @@ var ts; } function visitNodesInConvertedLoop(node) { switch (node.kind) { - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: node = isReturnVoidStatementInConstructorWithCapturedSuper(node) ? returnCapturedThis(node) : node; return visitReturnStatement(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitSwitchStatement(node); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: return visitBreakOrContinueStatement(node); case 98 /* ThisKeyword */: return visitThisKeyword(node); @@ -48983,77 +48697,77 @@ var ts; } function visitJavaScript(node) { switch (node.kind) { - case 83 /* ExportKeyword */: - return node; - case 222 /* ClassDeclaration */: + case 114 /* StaticKeyword */: + return undefined; // elide static keyword + case 225 /* ClassDeclaration */: return visitClassDeclaration(node); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return visitClassExpression(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return visitParameter(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return visitArrowFunction(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return visitVariableDeclaration(node); case 70 /* Identifier */: return visitIdentifier(node); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitLabeledStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return visitForOfStatement(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return visitExpressionStatement(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return visitCatchClause(node); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 12 /* NoSubstitutionTemplateLiteral */: case 13 /* TemplateHead */: case 14 /* TemplateMiddle */: case 15 /* TemplateTail */: return visitTemplateLiteral(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return visitTemplateExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitYieldExpression(node); case 96 /* SuperKeyword */: return visitSuperKeyword(); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: // `yield` will be handled by a generators transform. return ts.visitEachChild(node, visitor, context); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return visitSourceFileNode(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); default: ts.Debug.failBadSyntaxKind(node); @@ -49068,7 +48782,7 @@ var ts; } if (ts.isFunctionLike(currentNode)) { enclosingFunction = currentNode; - if (currentNode.kind !== 181 /* ArrowFunction */) { + if (currentNode.kind !== 184 /* ArrowFunction */) { enclosingNonArrowFunction = currentNode; if (!(ts.getEmitFlags(currentNode) & 2097152 /* AsyncFunctionBody */)) { enclosingNonAsyncFunctionBody = currentNode; @@ -49079,14 +48793,14 @@ var ts; // variable statements, variable declarations, binding elements, and binding // patterns. switch (currentNode.kind) { - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: enclosingVariableStatement = currentNode; break; - case 220 /* VariableDeclarationList */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 223 /* VariableDeclarationList */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: break; default: enclosingVariableStatement = undefined; @@ -49115,7 +48829,7 @@ var ts; } function visitThisKeyword(node) { ts.Debug.assert(convertedLoopState !== undefined); - if (enclosingFunction && enclosingFunction.kind === 181 /* ArrowFunction */) { + if (enclosingFunction && enclosingFunction.kind === 184 /* ArrowFunction */) { // if the enclosing function is an ArrowFunction is then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -49140,13 +48854,13 @@ 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 === 211 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 214 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels[node.label.text]) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 214 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -49157,7 +48871,7 @@ var ts; } } else { - if (node.kind === 211 /* BreakStatement */) { + if (node.kind === 214 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -49201,33 +48915,29 @@ var ts; // } // return C; // }()); - var modifierFlags = ts.getModifierFlags(node); - var isExported = modifierFlags & 1 /* Export */; - var isDefault = modifierFlags & 512 /* Default */; - // Add an `export` modifier to the statement if needed (for `--target es5 --module es6`) - var modifiers = isExported && !isDefault - ? ts.filter(node.modifiers, isExportModifier) - : undefined; - var statement = ts.createVariableStatement(modifiers, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(getDeclarationName(node, /*allowComments*/ true), - /*type*/ undefined, transformClassLikeDeclarationToExpression(node)) - ]), - /*location*/ node); + var variable = ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ true), + /*type*/ undefined, transformClassLikeDeclarationToExpression(node)); + ts.setOriginalNode(variable, node); + var statements = []; + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([variable]), /*location*/ node); ts.setOriginalNode(statement, node); ts.startOnNewLine(statement); + statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (isExported && isDefault) { - var statements = [statement]; - statements.push(ts.createExportAssignment( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*isExportEquals*/ false, getDeclarationName(node, /*allowComments*/ false))); - return statements; + if (ts.hasModifier(node, 1 /* Export */)) { + var exportStatement = ts.hasModifier(node, 512 /* Default */) + ? ts.createExportDefault(ts.getLocalName(node)) + : ts.createExternalModuleExport(ts.getLocalName(node)); + ts.setOriginalNode(exportStatement, statement); + statements.push(exportStatement); } - return statement; - } - function isExportModifier(node) { - return node.kind === 83 /* ExportKeyword */; + var emitFlags = ts.getEmitFlags(node); + if ((emitFlags & 33554432 /* HasEndOfDeclarationMarker */) === 0) { + // Add a DeclarationMarker as a marker for the end of the declaration + statements.push(ts.createEndOfDeclarationMarker(node)); + ts.setEmitFlags(statement, emitFlags | 33554432 /* HasEndOfDeclarationMarker */); + } + return ts.singleOrMany(statements); } /** * Visits a ClassExpression and transforms it into an expression. @@ -49282,7 +48992,7 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter("_super")] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "_super")] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier @@ -49317,7 +49027,7 @@ var ts; addClassMembers(statements, node); // Create a synthetic text range for the return statement. var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); - var localName = getLocalName(node); + var localName = ts.getLocalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); @@ -49341,7 +49051,7 @@ var ts; */ function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, getDeclarationName(node)), + statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), /*location*/ extendsClauseElement)); } } @@ -49358,7 +49068,7 @@ var ts; var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*asteriskToken*/ undefined, getDeclarationName(node), + /*asteriskToken*/ undefined, ts.getDeclarationName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), /*location*/ constructor || node); @@ -49409,8 +49119,8 @@ var ts; statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); } if (constructor) { - addDefaultValueAssignmentsIfNeeded(statements, constructor); - addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, /*convertObjectRest*/ false); + ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -49449,17 +49159,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 212 /* ReturnStatement */) { + if (statement.kind === 215 /* ReturnStatement */) { return true; } - else if (statement.kind === 204 /* IfStatement */) { + else if (statement.kind === 207 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 200 /* Block */) { + else if (statement.kind === 203 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -49476,7 +49186,7 @@ var ts; // If this isn't a derived class, just capture 'this' for arrow functions if necessary. if (!hasExtendsClause) { if (ctor) { - addCaptureThisForNodeIfNeeded(statements, ctor); + ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); } return 0 /* NoReplacement */; } @@ -49491,7 +49201,7 @@ var ts; // for something like property initializers. // Create a captured '_this' variable and assume it will subsequently be used. if (hasSynthesizedSuper) { - captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1 /* ReplaceSuperCapture */; } @@ -49517,7 +49227,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { var superCall = firstStatement.expression; superCallExpression = ts.setOriginalNode(saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), superCall); } @@ -49528,7 +49238,7 @@ var ts; return 2 /* ReplaceWithReturn */; } // Perform the capture. - captureThisForNode(statements, ctor, superCallExpression, firstStatement); + ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); // If we're actually replacing the original statement, we need to signal this to the caller. if (superCallExpression) { return 1 /* ReplaceSuperCapture */; @@ -49554,14 +49264,24 @@ var ts; else if (ts.isBindingPattern(node.name)) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. - return ts.setOriginalNode(ts.createParameter(ts.getGeneratedNameForNode(node), + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined, /*location*/ node), /*original*/ node); } else if (node.initializer) { // Initializers are elided - return ts.setOriginalNode(ts.createParameter(node.name, + return ts.setOriginalNode(ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, node.name, + /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined, /*location*/ node), /*original*/ node); @@ -49570,158 +49290,6 @@ var ts; return node; } } - /** - * Gets a value indicating whether we need to add default value assignments for a - * function-like node. - * - * @param node A function-like node. - */ - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 262144 /* ContainsDefaultValueAssignments */) !== 0; - } - /** - * Adds statements to the body of a function-like node if it contains parameters with - * binding patterns or initializers. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - */ - function addDefaultValueAssignmentsIfNeeded(statements, node) { - if (!shouldAddDefaultValueAssignments(node)) { - return; - } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - // A rest parameter cannot have a binding pattern or an initializer, - // so let's just ignore it. - if (dotDotDotToken) { - continue; - } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); - } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); - } - } - } - /** - * Adds statements to the body of a function-like node for parameters with binding patterns - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { - var temp = ts.getGeneratedNameForNode(parameter); - // In cases where a binding pattern is simply '[]' or '{}', - // we usually don't want to emit a var declaration; however, in the presence - // of an initializer, we must emit that expression to preserve side effects. - if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor))), 8388608 /* CustomPrologue */)); - } - else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608 /* CustomPrologue */)); - } - } - /** - * Adds statements to the body of a function-like node for parameters with initializers. - * - * @param statements The statements for the new function body. - * @param parameter The parameter for the function. - * @param name The name of the parameter. - * @param initializer The initializer for the parameter. - */ - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = ts.createIf(ts.createStrictEquality(ts.getSynthesizedClone(name), ts.createVoidZero()), ts.setEmitFlags(ts.createBlock([ - ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 1536 /* NoSourceMap */), ts.setEmitFlags(initializer, 1536 /* NoSourceMap */ | ts.getEmitFlags(initializer)), - /*location*/ parameter)) - ], /*location*/ parameter), 32 /* SingleLine */ | 1024 /* NoTrailingSourceMap */ | 12288 /* NoTokenSourceMaps */), - /*elseStatement*/ undefined, - /*location*/ parameter); - statement.startsOnNewLine = true; - ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 8388608 /* CustomPrologue */); - statements.push(statement); - } - /** - * Gets a value indicating whether we need to add statements to handle a rest parameter. - * - * @param node A ParameterDeclaration node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; - } - /** - * Adds statements to the body of a function-like node if it contains a rest parameter. - * - * @param statements The statements for the new function body. - * @param node A function-like node. - * @param inConstructorWithSynthesizedSuper A value indicating whether the parameter is - * part of a constructor declaration with a - * synthesized call to `super` - */ - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; - } - // `declarationName` is the name of the local declaration for the parameter. - var declarationName = ts.getMutableClone(parameter.name); - ts.setEmitFlags(declarationName, 1536 /* NoSourceMap */); - // `expressionName` is the name of the parameter used in expressions. - var expressionName = ts.getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = ts.createLoopVariable(); - // var param = []; - statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(declarationName, - /*type*/ undefined, ts.createArrayLiteral([])) - ]), - /*location*/ parameter), 8388608 /* CustomPrologue */)); - // for (var _i = restIndex; _i < arguments.length; _i++) { - // param[_i - restIndex] = arguments[_i]; - // } - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(temp, /*type*/ undefined, ts.createLiteral(restIndex)) - ], /*location*/ parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), - /*location*/ parameter), ts.createPostfixIncrement(temp, /*location*/ parameter), ts.createBlock([ - ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), - /*location*/ parameter)) - ])); - ts.setEmitFlags(forStatement, 8388608 /* CustomPrologue */); - ts.startOnNewLine(forStatement); - statements.push(forStatement); - } - /** - * Adds a statement to capture the `this` of a function declaration if it is needed. - * - * @param statements The statements for the new function body. - * @param node A node. - */ - function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 65536 /* ContainsCapturedLexicalThis */ && node.kind !== 181 /* ArrowFunction */) { - captureThisForNode(statements, node, ts.createThis()); - } - } - function captureThisForNode(statements, node, initializer, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration("_this", - /*type*/ undefined, initializer) - ]), originalStatement); - ts.setEmitFlags(captureThisStatement, 49152 /* NoComments */ | 8388608 /* CustomPrologue */); - ts.setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); - } /** * Adds statements to the class body function for a class to define the members of the * class. @@ -49733,20 +49301,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member)); break; - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors)); } break; - case 149 /* Constructor */: + case 150 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -49852,7 +49420,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 32768 /* ContainsLexicalThis */) { + if (node.transformFlags & 262144 /* ContainsLexicalThis */) { enableSubstitutionsForCapturedThis(); } var func = transformFunctionLikeToExpression(node, /*location*/ node, /*name*/ undefined); @@ -49876,7 +49444,7 @@ var ts; return ts.setOriginalNode(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, transformFunctionBody(node), + /*type*/ undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), /*location*/ node), /*original*/ node); } @@ -49889,91 +49457,17 @@ var ts; */ function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; - if (node.kind !== 181 /* ArrowFunction */) { + if (node.kind !== 184 /* ArrowFunction */) { enclosingNonArrowFunction = node; } var expression = ts.setOriginalNode(ts.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), - /*type*/ undefined, saveStateAndInvoke(node, transformFunctionBody), location), + /*type*/ undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), /*original*/ node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } - /** - * Transforms the body of a function-like node. - * - * @param node A function-like node. - */ - function transformFunctionBody(node) { - var multiLine = false; // indicates whether the block *must* be emitted as multiple lines - var singleLine = false; // indicates whether the block *may* be emitted as a single line - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - startLexicalEnvironment(); - if (ts.isBlock(body)) { - // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node); - addDefaultValueAssignmentsIfNeeded(statements, node); - addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false); - // If we added any generated statements, this must be a multi-line block. - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - // If the original body was a multi-line block, this must be a multi-line block. - if (!multiLine && body.multiLine) { - multiLine = true; - } - } - else { - ts.Debug.assert(node.kind === 181 /* 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 - // being emitted for the end position only. - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = ts.createReturn(expression, /*location*/ body); - ts.setEmitFlags(returnStatement, 12288 /* NoTokenSourceMaps */ | 1024 /* NoTrailingSourceMap */ | 32768 /* NoTrailingComments */); - statements.push(returnStatement); - // To align with the source map emit for the old emitter, we set a custom - // source map location for the close brace. - closeBraceLocation = body; - } - var lexicalEnvironment = endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - // If we added any final generated statements, this must be a multi-line block - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; - } - var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - ts.setEmitFlags(block, 32 /* SingleLine */); - } - if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); - } - ts.setOriginalNode(block, node.body); - return block; - } /** * Visits an ExpressionStatement that contains a destructuring assignment. * @@ -49982,9 +49476,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -50000,10 +49494,10 @@ var ts; // If we are here it is most likely because our expression is a destructuring assignment. if (needsDestructuringValue) { switch (node.expression.kind) { - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return ts.createParen(visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return ts.createParen(visitBinaryExpression(node.expression, /*needsDestructuringValue*/ true), /*location*/ node); } @@ -50032,7 +49526,7 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor); + assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*createAssignmentCallback*/ undefined, visitor); } else { assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); @@ -50065,7 +49559,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 8388608 /* ContainsBindingPattern */ + if (node.transformFlags & 67108864 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify @@ -50131,8 +49625,8 @@ var ts; && ts.isBlock(enclosingBlockScopeContainer) && ts.isIterationStatement(enclosingBlockScopeContainerParent, /*lookInLabeledStatements*/ false)); var emitExplicitInitializer = !emittedAsTopLevel - && enclosingBlockScopeContainer.kind !== 208 /* ForInStatement */ - && enclosingBlockScopeContainer.kind !== 209 /* ForOfStatement */ + && enclosingBlockScopeContainer.kind !== 211 /* ForInStatement */ + && enclosingBlockScopeContainer.kind !== 212 /* ForOfStatement */ && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction @@ -50213,118 +49707,7 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - // The following ES6 code: - // - // for (let v of expr) { } - // - // should be emitted as - // - // for (var _i = 0, _a = expr; _i < _a.length; _i++) { - // var v = _a[_i]; - // } - // - // where _a and _i are temps emitted to capture the RHS and the counter, - // respectively. - // When the left hand side is an expression instead of a let declaration, - // the "let v" is not emitted. - // When the left hand side is a let/const, the v is renamed if there is - // another v in scope. - // Note that all assignments to the LHS are emitted in the body, including - // all destructuring. - // Note also that because an extra statement is needed to assign to the LHS, - // for-of bodies are always emitted as blocks. - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - // In the case where the user wrote an identifier as the RHS, like this: - // - // for (let v of arr) { } - // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(expression.text) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, ts.createElementAccess(rhsReference, counter), visitor); - var declarationList = ts.createVariableDeclarationList(declarations, /*location*/ initializer); - ts.setOriginalNode(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ], /*location*/ ts.moveRangePos(initializer, -1)), - /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, ts.createElementAccess(rhsReference, counter)); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(context, assignment, - /*needsValue*/ false, hoistVariableDeclaration, visitor))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.createStatement(assignment, /*location*/ ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } - // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 1536 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.createNodeArray(statements, /*location*/ statementsLocation), - /*location*/ bodyLocation); - ts.setEmitFlags(body, 1536 /* NoSourceMap */ | 12288 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0), /*location*/ ts.moveRangePos(node.expression, -1)), - ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression, /*location*/ node.expression) - ], /*location*/ node.expression), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), - /*location*/ node.expression), ts.createPostfixIncrement(counter, /*location*/ node.expression), body, - /*location*/ node); - // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 8192 /* NoTokenTrailingSourceMaps */); - return forStatement; + return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, /*transformRest*/ false); } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -50340,8 +49723,8 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 16777216 /* ContainsYield */ - || property.name.kind === 141 /* ComputedPropertyName */) { + if (property.transformFlags & 134217728 /* ContainsYield */ + || property.name.kind === 142 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -50407,11 +49790,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 220 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 223 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -50460,7 +49843,7 @@ var ts; } var isAsyncBlockContainingAwait = enclosingNonArrowFunction && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152 /* AsyncFunctionBody */) !== 0 - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + && (node.statement.transformFlags & 134217728 /* ContainsYield */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 256 /* CapturesThis */; @@ -50469,14 +49852,14 @@ var ts; loopBodyFlags |= 2097152 /* AsyncFunctionBody */; } var convertedLoopVariable = ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList([ + /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) - ])); + ]), 16777216 /* NoHoisting */)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; // propagate state from the inner loop to the outer loop if necessary @@ -50558,7 +49941,7 @@ var ts; loop.transformFlags = 0; ts.aggregateTransformFlags(loop); } - statements.push(currentParent.kind === 215 /* LabeledStatement */ + statements.push(currentParent.kind === 218 /* LabeledStatement */ ? ts.createLabel(currentParent.label, loop) : loop); return statements; @@ -50664,7 +50047,7 @@ var ts; } } else { - loopParameters.push(ts.createParameter(name)); + loopParameters.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); if (resolver.getNodeCheckFlags(decl) & 2097152 /* NeedsLoopOutParameter */) { var outParamName = ts.createUniqueName("out_" + name.text); loopOutParameters.push({ originalName: name, outParamName: outParamName }); @@ -50686,20 +50069,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node.multiLine)); } break; - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node.multiLine)); break; default: @@ -50828,7 +50211,7 @@ var ts; ts.setEmitFlags(thisArg, 128 /* NoSubstitution */); } var resultingCall; - if (node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) { + if (node.transformFlags & 8388608 /* ContainsSpreadExpression */) { // [source] // f(...a, b) // x.m(...a, b) @@ -50874,7 +50257,7 @@ var ts; */ function visitNewExpression(node) { // We are here because we contain a SpreadElementExpression. - ts.Debug.assert((node.transformFlags & 1048576 /* ContainsSpreadElementExpression */) !== 0); + ts.Debug.assert((node.transformFlags & 8388608 /* ContainsSpreadExpression */) !== 0); // [source] // new C(...a) // @@ -50885,7 +50268,7 @@ var ts; /*typeArguments*/ undefined, []); } /** - * Transforms an array of Expression nodes that contains a SpreadElementExpression. + * Transforms an array of Expression nodes that contains a SpreadExpression. * * @param elements The array of Expression nodes. * @param needsUniqueCopy A value indicating whether to ensure that the result is a fresh array. @@ -50900,36 +50283,36 @@ var ts; // Map spans of spread expressions into their expressions and spans of other // expressions into an array literal. var numElements = elements.length; - var segments = ts.flatten(ts.spanMap(elements, partitionSpreadElement, function (partition, visitPartition, _start, end) { + var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElementExpression(firstElement) && firstElement.expression.kind !== 171 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 174 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } // Rewrite using the pattern .concat(, , ...) return ts.createArrayConcat(segments.shift(), segments); } - function partitionSpreadElement(node) { - return ts.isSpreadElementExpression(node) - ? visitSpanOfSpreadElements - : visitSpanOfNonSpreadElements; + function partitionSpread(node) { + return ts.isSpreadExpression(node) + ? visitSpanOfSpreads + : visitSpanOfNonSpreads; } - function visitSpanOfSpreadElements(chunk) { - return ts.map(chunk, visitExpressionOfSpreadElement); + function visitSpanOfSpreads(chunk) { + return ts.map(chunk, visitExpressionOfSpread); } - function visitSpanOfNonSpreadElements(chunk, multiLine, hasTrailingComma) { + function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, /*location*/ undefined, hasTrailingComma), visitor, ts.isExpression), /*location*/ undefined, multiLine); } /** - * Transforms the expression of a SpreadElementExpression node. + * Transforms the expression of a SpreadExpression node. * - * @param node A SpreadElementExpression node. + * @param node A SpreadExpression node. */ - function visitExpressionOfSpreadElement(node) { + function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } /** @@ -51086,7 +50469,7 @@ var ts; return enclosingNonAsyncFunctionBody && ts.isClassElement(enclosingNonAsyncFunctionBody) && !ts.hasModifier(enclosingNonAsyncFunctionBody, 32 /* Static */) - && currentParent.kind !== 175 /* CallExpression */ + && currentParent.kind !== 178 /* CallExpression */ ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } @@ -51095,7 +50478,7 @@ var ts; var statements = []; startLexicalEnvironment(); ts.addRange(statements, prologue); - addCaptureThisForNodeIfNeeded(statements, node); + ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); ts.addRange(statements, endLexicalEnvironment()); var clone = ts.getMutableClone(node); @@ -51134,21 +50517,20 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(149 /* Constructor */); - context.enableEmitNotification(148 /* MethodDeclaration */); - context.enableEmitNotification(150 /* GetAccessor */); - context.enableEmitNotification(151 /* SetAccessor */); - context.enableEmitNotification(181 /* ArrowFunction */); - context.enableEmitNotification(180 /* FunctionExpression */); - context.enableEmitNotification(221 /* FunctionDeclaration */); + context.enableEmitNotification(150 /* Constructor */); + context.enableEmitNotification(149 /* MethodDeclaration */); + context.enableEmitNotification(151 /* GetAccessor */); + context.enableEmitNotification(152 /* SetAccessor */); + context.enableEmitNotification(184 /* ArrowFunction */); + context.enableEmitNotification(183 /* FunctionExpression */); + context.enableEmitNotification(224 /* FunctionDeclaration */); } } /** * Hooks node substitutions. * + * @param emitContext The context for the emitter. * @param node The node to substitute. - * @param isExpression A value indicating whether the node is to be used in an expression - * position. */ function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -51183,10 +50565,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 170 /* BindingElement */: - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 222 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -51233,44 +50615,8 @@ var ts; } return node; } - /** - * Gets the local name for a declaration for use in expressions. - * - * A local name will *never* be prefixed with an module or namespace export modifier like - * "exports.". - * - * @param node The declaration. - * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. - */ - function getLocalName(node, allowComments, allowSourceMaps) { - return getDeclarationName(node, allowComments, allowSourceMaps, 262144 /* LocalName */); - } - /** - * Gets the name of a declaration, without source map or comments. - * - * @param node The declaration. - * @param allowComments Allow comments for the name. - */ - function getDeclarationName(node, allowComments, allowSourceMaps, emitFlags) { - if (node.name && !ts.isGeneratedIdentifier(node.name)) { - var name_38 = ts.getMutableClone(node.name); - emitFlags |= ts.getEmitFlags(node.name); - if (!allowSourceMaps) { - emitFlags |= 1536 /* NoSourceMap */; - } - if (!allowComments) { - emitFlags |= 49152 /* NoComments */; - } - if (emitFlags) { - ts.setEmitFlags(name_38, emitFlags); - } - return name_38; - } - return ts.getGeneratedNameForNode(node); - } function getClassMemberPrefix(node, member) { - var expression = getLocalName(node); + var expression = ts.getLocalName(node); return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { @@ -51282,11 +50628,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 203 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 206 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 175 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 178 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -51294,7 +50640,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 192 /* SpreadElementExpression */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 195 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -51536,7 +50882,7 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - if (node.transformFlags & 4096 /* ContainsGenerator */) { + if (node.transformFlags & 8192 /* ContainsGenerator */) { currentSourceFile = node; node = ts.visitEachChild(node, visitor, context); currentSourceFile = undefined; @@ -51556,10 +50902,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 2048 /* Generator */) { + else if (transformFlags & 4096 /* Generator */) { return visitGenerator(node); } - else if (transformFlags & 4096 /* ContainsGenerator */) { + else if (transformFlags & 8192 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -51573,13 +50919,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 205 /* DoStatement */: + case 208 /* DoStatement */: return visitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return visitWhileStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return visitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -51592,30 +50938,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return visitAccessorDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return visitVariableStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return visitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return visitForInStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return visitBreakStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return visitContinueStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 16777216 /* ContainsYield */) { + if (node.transformFlags & 134217728 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (4096 /* ContainsGenerator */ | 33554432 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (8192 /* ContainsGenerator */ | 268435456 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -51630,21 +50976,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return visitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return visitConditionalExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return visitYieldExpression(node); - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return visitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -51657,9 +51003,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -51820,7 +51166,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 16777216 /* ContainsYield */) { + if (node.transformFlags & 134217728 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -51888,7 +51234,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -51900,7 +51246,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -52269,35 +51615,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 200 /* Block */: + case 203 /* Block */: return transformAndEmitBlock(node); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return transformAndEmitIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return transformAndEmitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return transformAndEmitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return transformAndEmitWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); @@ -52717,7 +52063,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 250 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 253 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -52730,7 +52076,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 249 /* CaseClause */) { + if (clause.kind === 252 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -52861,7 +52207,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; + return node && (node.transformFlags & 134217728 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -52891,9 +52237,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_39) { - var clone_8 = ts.getMutableClone(name_39); + var name_35 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_35) { + var clone_8 = ts.getMutableClone(name_35); ts.setSourceMapRange(clone_8, node); ts.setCommentRange(clone_8, node); return clone_8; @@ -53295,7 +52641,7 @@ var ts; if (labelExpressions === undefined) { labelExpressions = []; } - var expression = ts.createSynthesizedNode(8 /* NumericLiteral */); + var expression = ts.createLiteral(-1); if (labelExpressions[label] === undefined) { labelExpressions[label] = [expression]; } @@ -53304,7 +52650,7 @@ var ts; } return expression; } - return ts.createNode(194 /* OmittedExpression */); + return ts.createOmittedExpression(); } /** * Creates a numeric literal for the provided instruction. @@ -53489,7 +52835,7 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, [ts.createParameter(state)], + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, /*location*/ undefined, /*multiLine*/ buildResult.length > 0)), 4194304 /* ReuseTempVariableScope */) @@ -53879,8 +53225,8 @@ var ts; function transformES5(context) { var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(173 /* PropertyAccessExpression */); - context.enableSubstitution(253 /* PropertyAssignment */); + context.enableSubstitution(176 /* PropertyAccessExpression */); + context.enableSubstitution(256 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53945,9 +53291,2452 @@ var ts; } ts.transformES5 = transformES5; })(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformES2015Module(context) { + var compilerOptions = context.getCompilerOptions(); + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + return ts.visitEachChild(node, visitor, context); + } + return node; + } + function visitor(node) { + switch (node.kind) { + case 233 /* ImportEqualsDeclaration */: + // Elide `import=` as it is not legal with --module ES6 + return undefined; + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + } + return node; + } + function visitExportAssignment(node) { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; + } + } + ts.transformES2015Module = transformES2015Module; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformSystemModule(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(191 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(189 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(190 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(260 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. + var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + var exportFunctionsMap = ts.createMap(); // The export function associated with a source file. + var noSubstitutionMap = ts.createMap(); // Set of nodes for which substitution rules should be ignored for each file. + var currentSourceFile; // The current file. + var moduleInfo; // ExternalModuleInfo for the current file. + var exportFunction; // The export function for the current file. + var contextObject; // The context object for the current file. + var hoistedStatements; + var enclosingBlockScopedContainer; + var noSubstitution; // Set of nodes for which substitution rules should be ignored. + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + enclosingBlockScopedContainer = node; + // System modules have the following shape: + // + // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) + // + // The parameter 'exports' here is a callback '(name: string, value: T) => T' that + // is used to publish exported values. 'exports' returns its 'value' argument so in + // most cases expressions that mutate exported values can be rewritten as: + // + // expr -> exports('name', expr) + // + // The only exception in this rule is postfix unary operators, + // see comment to 'substitutePostfixUnaryExpression' for more details + // Collect information about the external module and dependency groups. + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + // Make sure that the name of the 'exports' function does not conflict with + // existing identifiers. + exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); + contextObject = ts.createUniqueName("context"); + // Add the body of the module. + var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyFunction = ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, exportFunction), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, contextObject) + ], + /*type*/ undefined, createSystemModuleBody(node, dependencyGroups)); + // Write the call to `System.register` + // Clear the emit-helpers flag for later passes since we'll have already used it in the module body + // So the helper will be emit at the correct position instead of at the top of the source-file + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("System"), "register"), + /*typeArguments*/ undefined, moduleName + ? [moduleName, dependencies, moduleBodyFunction] + : [dependencies, moduleBodyFunction])) + ], node.statements)); + ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1 /* EmitEmitHelpers */); + if (noSubstitution) { + noSubstitutionMap[id] = noSubstitution; + noSubstitution = undefined; + } + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + contextObject = undefined; + hoistedStatements = undefined; + enclosingBlockScopedContainer = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Collects the dependency groups for this files imports. + * + * @param externalImports The imports for the file. + */ + function collectDependencyGroups(externalImports) { + var groupIndices = ts.createMap(); + var dependencyGroups = []; + for (var i = 0; i < externalImports.length; i++) { + var externalImport = externalImports[i]; + var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); + var text = externalModuleName.text; + if (ts.hasProperty(groupIndices, text)) { + // deduplicate/group entries in dependency list by the dependency name + var groupIndex = groupIndices[text]; + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices[text] = dependencyGroups.length; + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } + } + return dependencyGroups; + } + /** + * Adds the statements for the module body function for the source file. + * + * @param node The source file for the module. + * @param dependencyGroups The grouped dependencies of the module. + */ + function createSystemModuleBody(node, dependencyGroups) { + // Shape of the body in system modules: + // + // function (exports) { + // + // + // + // return { + // setters: [ + // + // ], + // execute: function() { + // + // } + // } + // + // } + // + // i.e: + // + // import {x} from 'file1' + // var y = 1; + // export function foo() { return y + x(); } + // console.log(y); + // + // Will be transformed to: + // + // function(exports) { + // function foo() { return y + file_1.x(); } + // exports("foo", foo); + // var file_1, y; + // return { + // setters: [ + // function(v) { file_1 = v } + // ], + // execute(): function() { + // y = 1; + // console.log(y); + // } + // }; + // } + var statements = []; + // We start a new lexical environment in this function body, but *not* in the + // body of the execute function. This allows us to emit temporary declarations + // only in the outer module body and not in the inner one. + startLexicalEnvironment(); + // Add any prologue directives. + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + // var __moduleName = context_1 && context_1.id; + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("__moduleName", + /*type*/ undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) + ]))); + // Visit the statements of the source file, emitting any transformations into + // the `executeStatements` array. We do this *before* we fill the `setters` array + // as we both emit transformations as well as aggregate some data used when creating + // setters. This allows us to reduce the number of times we need to loop through the + // statements of the source file. + var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); + // Emit early exports for function declarations. + ts.addRange(statements, hoistedStatements); + // We emit hoisted variables early to align roughly with our previous emit output. + // Two key differences in this approach are: + // - Temporary variables will appear at the top rather than at the bottom of the file + ts.addRange(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); + statements.push(ts.createReturn(ts.setMultiLine(ts.createObjectLiteral([ + ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), + ts.createPropertyAssignment("execute", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock(executeStatements, + /*location*/ undefined, + /*multiLine*/ true))) + ]), + /*multiLine*/ true))); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + ts.setEmitFlags(body, 1 /* EmitEmitHelpers */); + return body; + } + /** + * Adds an exportStar function to a statement list if it is needed for the file. + * + * @param statements A statement list. + */ + function addExportStarIfNeeded(statements) { + if (!moduleInfo.hasExportStarsToExportValues) { + return; + } + // when resolving exports local exported entries/indirect exported entries in the module + // should always win over entries with similar names that were added via star exports + // to support this we store names of local/indirect exported entries in a set. + // this set is used to filter names brought by star expors. + // local names set should only be added if we have anything exported + if (!moduleInfo.exportedNames && ts.isEmpty(moduleInfo.exportSpecifiers)) { + // no exported declarations (export var ...) or export specifiers (export {x}) + // check if we have any non star export declarations. + var hasExportDeclarationWithExportClause = false; + for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { + var externalImport = _a[_i]; + if (externalImport.kind === 240 /* ExportDeclaration */ && externalImport.exportClause) { + hasExportDeclarationWithExportClause = true; + break; + } + } + if (!hasExportDeclarationWithExportClause) { + // we still need to emit exportStar helper + var exportStarFunction_1 = createExportStarFunction(/*localNames*/ undefined); + statements.push(exportStarFunction_1); + return exportStarFunction_1.name; + } + } + var exportedNames = []; + if (moduleInfo.exportedNames) { + for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) { + var exportedLocalName = _c[_b]; + if (exportedLocalName.text === "default") { + continue; + } + // write name of exported declaration, i.e 'export var x...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral(exportedLocalName), ts.createLiteral(true))); + } + } + for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { + var externalImport = _e[_d]; + if (externalImport.kind !== 240 /* ExportDeclaration */) { + continue; + } + var exportDecl = externalImport; + if (!exportDecl.exportClause) { + // export * from ... + continue; + } + for (var _f = 0, _g = exportDecl.exportClause.elements; _f < _g.length; _f++) { + var element = _g[_f]; + // write name of indirectly exported entry, i.e. 'export {x} from ...' + exportedNames.push(ts.createPropertyAssignment(ts.createLiteral((element.name || element.propertyName).text), ts.createLiteral(true))); + } + } + var exportedNamesStorageRef = ts.createUniqueName("exportedNames"); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exportedNamesStorageRef, + /*type*/ undefined, ts.createObjectLiteral(exportedNames, /*location*/ undefined, /*multiline*/ true)) + ]))); + var exportStarFunction = createExportStarFunction(exportedNamesStorageRef); + statements.push(exportStarFunction); + return exportStarFunction.name; + } + /** + * Creates an exportStar function for the file, with an optional set of excluded local + * names. + * + * @param localNames An optional reference to an object containing a set of excluded local + * names. + */ + function createExportStarFunction(localNames) { + var exportStarFunction = ts.createUniqueName("exportStar"); + var m = ts.createIdentifier("m"); + var n = ts.createIdentifier("n"); + var exports = ts.createIdentifier("exports"); + var condition = ts.createStrictInequality(n, ts.createLiteral("default")); + if (localNames) { + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + } + return ts.createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, exportStarFunction, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, m)], + /*type*/ undefined, ts.createBlock([ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(exports, + /*type*/ undefined, ts.createObjectLiteral([])) + ])), + ts.createForIn(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(n, /*type*/ undefined) + ]), m, ts.createBlock([ + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32 /* SingleLine */) + ])), + ts.createStatement(ts.createCall(exportFunction, + /*typeArguments*/ undefined, [exports])) + ], + /*location*/ undefined, + /*multiline*/ true)); + } + /** + * Creates an array setter callbacks for each dependency group. + * + * @param exportStarFunction A reference to an exportStarFunction for the file. + * @param dependencyGroups An array of grouped dependencies. + */ + function createSettersArray(exportStarFunction, dependencyGroups) { + var setters = []; + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var group = dependencyGroups_1[_i]; + // derive a unique name for parameter from the first named entry in the group + var localName = ts.forEach(group.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); + var statements = []; + for (var _a = 0, _b = group.externalImports; _a < _b.length; _a++) { + var entry = _b[_a]; + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + switch (entry.kind) { + case 234 /* ImportDeclaration */: + if (!entry.importClause) { + // 'import "..."' case + // module is imported only for side-effects, no emit required + break; + } + // fall-through + case 233 /* ImportEqualsDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + // save import into the local + statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); + break; + case 240 /* ExportDeclaration */: + ts.Debug.assert(importVariableName !== undefined); + if (entry.exportClause) { + // export {a, b as c} from 'foo' + // + // emit as: + // + // exports_({ + // "a": _["a"], + // "c": _["b"] + // }); + var properties = []; + for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) { + var e = _d[_c]; + properties.push(ts.createPropertyAssignment(ts.createLiteral(e.name.text), ts.createElementAccess(parameterName, ts.createLiteral((e.propertyName || e.name).text)))); + } + statements.push(ts.createStatement(ts.createCall(exportFunction, + /*typeArguments*/ undefined, [ts.createObjectLiteral(properties, /*location*/ undefined, /*multiline*/ true)]))); + } + else { + // export * from 'foo' + // + // emit as: + // + // exportStar(foo_1_1); + statements.push(ts.createStatement(ts.createCall(exportStarFunction, + /*typeArguments*/ undefined, [parameterName]))); + } + break; + } + } + setters.push(ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], + /*type*/ undefined, ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true))); + } + return ts.createArrayLiteral(setters, /*location*/ undefined, /*multiLine*/ true); + } + // + // Top-level Source Element Visitors + // + /** + * Visit source elements at the top-level of a module. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + switch (node.kind) { + case 234 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 233 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 240 /* ExportDeclaration */: + // ExportDeclarations are elided as they are handled via + // `appendExportsOfDeclaration`. + return undefined; + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + default: + return nestedElementVisitor(node); + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + if (node.importClause) { + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; + } + var expression = ts.visitNode(node.expression, destructuringVisitor, ts.isExpression); + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), expression, /*allowComments*/ true); + } + else { + return createExportStatement(ts.createIdentifier("default"), expression, /*allowComments*/ true); + } + } + /** + * Visits a FunctionDeclaration, hoisting it to the outer module body function. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + if (ts.hasModifier(node, 1 /* Export */)) { + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), + /*type*/ undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + } + else { + hoistedStatements = ts.append(hoistedStatements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node); + } + return undefined; + } + /** + * Visits a ClassDeclaration, hoisting its name to the outer module body function. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + // Hoist the name of the class declaration to the outer module body function. + var name = ts.getLocalName(node); + hoistVariableDeclaration(name); + // Rewrite the class declaration into an assignment of a class expression. + statements = ts.append(statements, ts.createStatement(ts.createAssignment(name, ts.createClassExpression( + /*modifiers*/ undefined, node.name, + /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, destructuringVisitor, ts.isHeritageClause), ts.visitNodes(node.members, destructuringVisitor, ts.isClassElement), + /*location*/ node)), + /*location*/ node)); + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a variable statement, hoisting declared names to the top-level module body. + * Each declaration is rewritten into an assignment expression. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + if (!shouldHoistVariableDeclarationList(node.declarationList)) { + return ts.visitNode(node, destructuringVisitor, ts.isStatement); + } + var expressions; + var isExportedDeclaration = ts.hasModifier(node, 1 /* Export */); + var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } + var statements; + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + } + if (isMarkedDeclaration) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration); + } + else { + statements = appendExportsOfVariableStatement(statements, node, /*exportSelf*/ false); + } + return ts.singleOrMany(statements); + } + /** + * Hoists the declared names of a VariableDeclaration or BindingElement. + * + * @param node The declaration to hoist. + */ + function hoistBindingElement(node) { + if (ts.isBindingPattern(node.name)) { + for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + hoistBindingElement(element); + } + } + } + else { + hoistVariableDeclaration(ts.getSynthesizedClone(node.name)); + } + } + /** + * Determines whether a VariableDeclarationList should be hoisted. + * + * @param node The node to test. + */ + function shouldHoistVariableDeclarationList(node) { + // hoist only non-block scoped declarations or block scoped declarations parented by source file + return (ts.getEmitFlags(node) & 16777216 /* NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 260 /* SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + } + /** + * Transform an initialized variable declaration into an expression. + * + * @param node The node to transform. + * @param isExportedDeclaration A value indicating whether the variable is exported. + */ + function transformInitializedVariable(node, isExportedDeclaration) { + var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; + return ts.isBindingPattern(node.name) + ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); + } + /** + * Creates an assignment expression for an exported variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + */ + function createExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, /*isExportedDeclaration*/ true); + } + /** + * Creates an assignment expression for a non-exported variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + */ + function createNonExportedVariableAssignment(name, value, location) { + return createVariableAssignment(name, value, location, /*isExportedDeclaration*/ false); + } + /** + * Creates an assignment expression for a variable declaration. + * + * @param name The name of the variable. + * @param value The value of the variable's initializer. + * @param location The source map location for the assignment. + * @param isExportedDeclaration A value indicating whether the variable is exported. + */ + function createVariableAssignment(name, value, location, isExportedDeclaration) { + hoistVariableDeclaration(ts.getSynthesizedClone(name)); + return isExportedDeclaration + ? createExportExpression(name, preventSubstitution(ts.createAssignment(name, value, location))) + : preventSubstitution(ts.createAssignment(name, value, location)); + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // 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 === 204 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); + } + return node; + } + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the export of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + * @param exportSelf A value indicating whether to also export each VariableDeclaration of + * `nodes` declaration list. + */ + function appendExportsOfVariableStatement(statements, node, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.initializer || exportSelf) { + statements = appendExportsOfBindingElement(statements, decl, exportSelf); + } + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + * @param exportSelf A value indicating whether to also export the declaration itself. + */ + function appendExportsOfBindingElement(statements, decl, exportSelf) { + if (moduleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element, exportSelf); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + var excludeName = void 0; + if (exportSelf) { + statements = appendExportStatement(statements, decl.name, ts.getLocalName(decl)); + excludeName = decl.name.text; + } + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (moduleInfo.exportEquals) { + return statements; + } + var excludeName; + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createLiteral("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl)); + excludeName = exportName.text; + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl, excludeName); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + * @param excludeName An optional name to exclude from exports. + */ + function appendExportsOfDeclaration(statements, decl, excludeName) { + if (moduleInfo.exportEquals) { + return statements; + } + var name = ts.getDeclarationName(decl); + var exportSpecifiers = moduleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { + var exportSpecifier = exportSpecifiers_1[_i]; + if (exportSpecifier.name.text !== excludeName) { + statements = appendExportStatement(statements, exportSpecifier.name, name); + } + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, allowComments) { + statements = ts.append(statements, createExportStatement(exportName, expression, allowComments)); + return statements; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value)); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + */ + function createExportExpression(name, value) { + var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; + return ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + } + // + // Top-Level or Nested Source Element Visitors + // + /** + * Visit nested elements at the top-level of a module. + * + * @param node The node to visit. + */ + function nestedElementVisitor(node) { + switch (node.kind) { + case 204 /* VariableStatement */: + return visitVariableStatement(node); + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 225 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 210 /* ForStatement */: + return visitForStatement(node); + case 211 /* ForInStatement */: + return visitForInStatement(node); + case 212 /* ForOfStatement */: + return visitForOfStatement(node); + case 208 /* DoStatement */: + return visitDoStatement(node); + case 209 /* WhileStatement */: + return visitWhileStatement(node); + case 218 /* LabeledStatement */: + return visitLabeledStatement(node); + case 216 /* WithStatement */: + return visitWithStatement(node); + case 217 /* SwitchStatement */: + return visitSwitchStatement(node); + case 231 /* CaseBlock */: + return visitCaseBlock(node); + case 252 /* CaseClause */: + return visitCaseClause(node); + case 253 /* DefaultClause */: + return visitDefaultClause(node); + case 220 /* TryStatement */: + return visitTryStatement(node); + case 255 /* CatchClause */: + return visitCatchClause(node); + case 203 /* Block */: + return visitBlock(node); + case 293 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 294 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + return destructuringVisitor(node); + } + } + /** + * Visits the body of a ForStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a ForInStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForInStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a ForOfStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitForOfStatement(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Determines whether to hoist the initializer of a ForStatement, ForInStatement, or + * ForOfStatement. + * + * @param node The node to test. + */ + function shouldHoistForInitializer(node) { + return ts.isVariableDeclarationList(node) + && shouldHoistVariableDeclarationList(node); + } + /** + * Visits the initializer of a ForStatement, ForInStatement, or ForOfStatement + * + * @param node The node to visit. + */ + function visitForInitializer(node) { + if (shouldHoistForInitializer(node)) { + var expressions = void 0; + for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + expressions = ts.append(expressions, transformInitializedVariable(variable, /*isExportedDeclaration*/ false)); + } + return expressions ? ts.inlineExpressions(expressions) : ts.createOmittedExpression(); + } + else { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + } + /** + * Visits the body of a DoStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitDoStatement(node) { + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + } + /** + * Visits the body of a WhileStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitWhileStatement(node) { + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a LabeledStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitLabeledStatement(node) { + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a WithStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitWithStatement(node) { + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + } + /** + * Visits the body of a SwitchStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitSwitchStatement(node) { + return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); + } + /** + * Visits the body of a CaseBlock to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a CaseClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitCaseClause(node) { + return ts.updateCaseClause(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement)); + } + /** + * Visits the body of a DefaultClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitDefaultClause(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + /** + * Visits the body of a TryStatement to hoist declarations. + * + * @param node The node to visit. + */ + function visitTryStatement(node) { + return ts.visitEachChild(node, nestedElementVisitor, context); + } + /** + * Visits the body of a CatchClause to hoist declarations. + * + * @param node The node to visit. + */ + function visitCatchClause(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock)); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + /** + * Visits the body of a Block to hoist declarations. + * + * @param node The node to visit. + */ + function visitBlock(node) { + var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; + enclosingBlockScopedContainer = node; + node = ts.visitEachChild(node, nestedElementVisitor, context); + enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; + return node; + } + // + // Destructuring Assignment Visitors + // + /** + * Visit nodes to flatten destructuring assignments to exported symbols. + * + * @param node The node to visit. + */ + function destructuringVisitor(node) { + if (node.transformFlags & 16384 /* DestructuringAssignment */ + && node.kind === 191 /* BinaryExpression */) { + return visitDestructuringAssignment(node); + } + else if (node.transformFlags & 32768 /* ContainsDestructuringAssignment */) { + return ts.visitEachChild(node, destructuringVisitor, context); + } + else { + return node; + } + } + /** + * Visits a DestructuringAssignment to flatten destructuring to exported symbols. + * + * @param node The node to visit. + */ + function visitDestructuringAssignment(node) { + if (hasExportedReferenceInDestructuringTarget(node.left)) { + return ts.flattenDestructuringAssignment(context, node, /*needsValue*/ true, hoistVariableDeclaration, destructuringVisitor); + } + return ts.visitEachChild(node, destructuringVisitor, context); + } + /** + * Determines whether the target of a destructuring assigment refers to an exported symbol. + * + * @param node The destructuring target. + */ + function hasExportedReferenceInDestructuringTarget(node) { + if (ts.isAssignmentExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.left); + } + else if (ts.isSpreadExpression(node)) { + return hasExportedReferenceInDestructuringTarget(node.expression); + } + else if (ts.isObjectLiteralExpression(node)) { + return ts.some(node.properties, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isArrayLiteralExpression(node)) { + return ts.some(node.elements, hasExportedReferenceInDestructuringTarget); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.name); + } + else if (ts.isPropertyAssignment(node)) { + return hasExportedReferenceInDestructuringTarget(node.initializer); + } + else if (ts.isIdentifier(node)) { + var container = resolver.getReferencedExportContainer(node); + return container !== undefined && container.kind === 260 /* SourceFile */; + } + else { + return false; + } + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; + } + // + // Emit Notification + // + /** + * Hook for node emit notifications. + * + * @param emitContext A context hint for the emitter. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260 /* SourceFile */) { + var id = ts.getOriginalNodeId(node); + currentSourceFile = node; + moduleInfo = moduleInfoMap[id]; + exportFunction = exportFunctionsMap[id]; + noSubstitution = noSubstitutionMap[id]; + if (noSubstitution) { + delete noSubstitutionMap[id]; + } + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + moduleInfo = undefined; + exportFunction = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param emitContext A context hint for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (isSubstitutionPrevented(node)) { + return node; + } + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + return node; + } + /** + * Substitute the expression, if necessary. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 191 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 189 /* PrefixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpressionIdentifier(node) { + // When we see an identifier in an expression position that + // points to an imported symbol, we should substitute a qualified + // reference to the imported symbol if one is needed. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(importDeclaration.propertyName || importDeclaration.name), + /*location*/ node); + } + } + } + return node; + } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) { + var exportName = exportedNames_1[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 /* PostfixUnaryExpression */ + ? ts.createPrefix(node.operator, node.operand, + /*location*/ node) + : node; + for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { + var exportName = exportedNames_2[_i]; + expression = createExportExpression(exportName, preventSubstitution(expression)); + } + if (node.kind === 190 /* PostfixUnaryExpression */) { + expression = node.operator === 42 /* PlusPlusToken */ + ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) + : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); + } + return expression; + } + } + return node; + } + /** + * Gets the exports of a name. + * + * @param name The name. + */ + function getExports(name) { + var exportedNames; + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); + if (exportContainer && exportContainer.kind === 260 /* SourceFile */) { + exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); + } + exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); + } + } + return exportedNames; + } + /** + * Prevent substitution of a node for this transformer. + * + * @param node The node which should not be substituted. + */ + function preventSubstitution(node) { + if (noSubstitution === undefined) + noSubstitution = ts.createMap(); + noSubstitution[ts.getNodeId(node)] = true; + return node; + } + /** + * Determines whether a node should not be substituted. + * + * @param node The node to test. + */ + function isSubstitutionPrevented(node) { + return noSubstitution && node.id && noSubstitution[node.id]; + } + } + ts.transformSystemModule = transformSystemModule; +})(ts || (ts = {})); +/// +/// +/*@internal*/ +var ts; +(function (ts) { + function transformModule(context) { + var transformModuleDelegates = ts.createMap((_a = {}, + _a[ts.ModuleKind.None] = transformCommonJSModule, + _a[ts.ModuleKind.CommonJS] = transformCommonJSModule, + _a[ts.ModuleKind.AMD] = transformAMDModule, + _a[ts.ModuleKind.UMD] = transformUMDModule, + _a)); + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); + var resolver = context.getEmitResolver(); + var host = context.getEmitHost(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var moduleKind = ts.getEmitModuleKind(compilerOptions); + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(191 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(189 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(190 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(257 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(260 /* SourceFile */); // Restore state when substituting nodes in a file. + var moduleInfoMap = ts.createMap(); // The ExternalModuleInfo for each file. + var deferredExports = ts.createMap(); // Exports to defer until an EndOfDeclarationMarker is found. + var currentSourceFile; // The current file. + var currentModuleInfo; // The ExternalModuleInfo for the current file. + var noSubstitution; // Set of nodes for which substitution rules should be ignored. + return transformSourceFile; + /** + * Transforms the module aspects of a SourceFile. + * + * @param node The SourceFile node. + */ + function transformSourceFile(node) { + if (ts.isDeclarationFile(node) + || !(ts.isExternalModule(node) + || compilerOptions.isolatedModules)) { + return node; + } + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + // Perform the transformation. + var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; + var updated = transformModule(node); + currentSourceFile = undefined; + currentModuleInfo = undefined; + return ts.aggregateTransformFlags(updated); + } + /** + * Transforms a SourceFile into a CommonJS module. + * + * @param node The SourceFile node. + */ + function transformCommonJSModule(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + if (currentModuleInfo.hasExportStarsToExportValues) { + ts.setEmitFlags(updated, 2 /* EmitExportStar */ | ts.getEmitFlags(node)); + } + return updated; + } + /** + * Transforms a SourceFile into an AMD module. + * + * @param node The SourceFile node. + */ + function transformAMDModule(node) { + var define = ts.createIdentifier("define"); + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); + return transformAsynchronousModule(node, define, moduleName, /*includeNonAmdDependencies*/ true); + } + /** + * Transforms a SourceFile into a UMD module. + * + * @param node The SourceFile node. + */ + function transformUMDModule(node) { + var define = ts.createIdentifier("define"); + ts.setEmitFlags(define, 16 /* UMDDefine */); + return transformAsynchronousModule(node, define, /*moduleName*/ undefined, /*includeNonAmdDependencies*/ false); + } + /** + * Transforms a SourceFile into an AMD or UMD module. + * + * @param node The SourceFile node. + * @param define The expression used to define the module. + * @param moduleName An expression for the module name, if available. + * @param includeNonAmdDependencies A value indicating whether to incldue any non-AMD dependencies. + */ + function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { + // An AMD define function has the following shape: + // + // define(id?, dependencies?, factory); + // + // This has the shape of the following: + // + // define(name, ["module1", "module2"], function (module1Alias) { ... } + // + // The location of the alias in the parameter list in the factory function needs to + // match the position of the module name in the dependency list. + // + // To ensure this is true in cases of modules with no aliases, e.g.: + // + // import "module" + // + // or + // + // /// + // + // we need to add modules without alias names to the end of the dependencies list + var _a = collectAsynchronousDependencies(node, includeNonAmdDependencies), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + // Create an updated SourceFile: + // + // define(moduleName?, ["module1", "module2"], function ... + return ts.updateSourceFileNode(node, ts.createNodeArray([ + ts.createStatement(ts.createCall(define, + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ + // Add the dependency array argument: + // + // ["require", "exports", module1", "module2", ...] + ts.createArrayLiteral([ + ts.createLiteral("require"), + ts.createLiteral("exports") + ].concat(aliasedModuleNames, unaliasedModuleNames)), + // Add the module body function argument: + // + // function (require, exports, module1, module2) ... + ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, [ + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports") + ].concat(importAliasNames), + /*type*/ undefined, transformAsynchronousModuleBody(node)) + ]))) + ], + /*location*/ node.statements)); + } + /** + * Collect the additional asynchronous dependencies for the module. + * + * @param node The source file. + * @param includeNonAmdDependencies A value indicating whether to include non-AMD dependencies. + */ + function collectAsynchronousDependencies(node, includeNonAmdDependencies) { + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding + // module names in aliasedModuleNames. + var importAliasNames = []; + // Fill in amd-dependency tags + for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) { + var amdDependency = _a[_i]; + if (amdDependency.name) { + aliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); + } + else { + unaliasedModuleNames.push(ts.createLiteral(amdDependency.path)); + } + } + for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) { + var importNode = _c[_b]; + // Find the name of the external module + var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + // Find the name of the module alias, if there is one + var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 128 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } + } + return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; + } + /** + * Transforms a SourceFile into an AMD or UMD module body. + * + * @param node The SourceFile node. + */ + function transformAsynchronousModuleBody(node) { + startLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + // Visit each statement of the module body. + ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // End the lexical environment for the module body + // and merge any new lexical declarations. + ts.addRange(statements, endLexicalEnvironment()); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); + var body = ts.createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. + ts.setEmitFlags(body, 2 /* EmitExportStar */); + } + return body; + } + /** + * Adds the down-level representation of `export=` to the statement list if one exists + * in the source file. + * + * @param statements The Statement list to modify. + * @param emitAsReturn A value indicating whether to emit the `export=` statement as a + * return statement. + */ + function addExportEqualsIfNeeded(statements, emitAsReturn) { + if (currentModuleInfo.exportEquals) { + if (emitAsReturn) { + var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, + /*location*/ currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 12288 /* NoTokenSourceMaps */ | 49152 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), + /*location*/ currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 49152 /* NoComments */); + statements.push(statement); + } + } + } + // + // Top-Level Source Element Visitors + // + /** + * Visits a node at the top level of the source file. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node) { + switch (node.kind) { + case 234 /* ImportDeclaration */: + return visitImportDeclaration(node); + case 233 /* ImportEqualsDeclaration */: + return visitImportEqualsDeclaration(node); + case 240 /* ExportDeclaration */: + return visitExportDeclaration(node); + case 239 /* ExportAssignment */: + return visitExportAssignment(node); + case 204 /* VariableStatement */: + return visitVariableStatement(node); + case 224 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 225 /* ClassDeclaration */: + return visitClassDeclaration(node); + case 293 /* MergeDeclarationMarker */: + return visitMergeDeclarationMarker(node); + case 294 /* EndOfDeclarationMarker */: + return visitEndOfDeclarationMarker(node); + default: + // This visitor does not descend into the tree, as export/import statements + // are only transformed at the top level of a file. + return node; + } + } + /** + * Visits an ImportDeclaration node. + * + * @param node The node to visit. + */ + function visitImportDeclaration(node) { + var statements; + var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); + if (moduleKind !== ts.ModuleKind.AMD) { + if (!node.importClause) { + // import "mod"; + return ts.createStatement(createRequireCall(node), /*location*/ node); + } + else { + var variables = []; + if (namespaceDeclaration && !ts.isDefaultImport(node)) { + // import * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, createRequireCall(node))); + } + else { + // import d from "mod"; + // import { x, y } from "mod"; + // import d, { x, y } from "mod"; + // import d, * as n from "mod"; + variables.push(ts.createVariableDeclaration(ts.getGeneratedNameForNode(node), + /*type*/ undefined, createRequireCall(node))); + if (namespaceDeclaration && ts.isDefaultImport(node)) { + variables.push(ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node))); + } + } + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList(variables, + /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); + } + } + else if (namespaceDeclaration && ts.isDefaultImport(node)) { + // import d, * as n from "mod"; + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(namespaceDeclaration.name), + /*type*/ undefined, ts.getGeneratedNameForNode(node), + /*location*/ node) + ], + /*location*/ undefined, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + return ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + if (moduleKind !== ts.ModuleKind.AMD) { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(node.name, createRequireCall(node)), + /*location*/ node)); + } + else { + statements = ts.append(statements, ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedClone(node.name), + /*type*/ undefined, createRequireCall(node)) + ], + /*location*/ undefined, + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */), + /*location*/ node)); + } + } + else { + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.getExportName(node), ts.getLocalName(node)), + /*location*/ node)); + } + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfImportEqualsDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits an ExportDeclaration node. + * + * @param The node to visit. + */ + function visitExportDeclaration(node) { + if (!node.moduleSpecifier) { + // Elide export declarations with no module specifier as they are handled + // elsewhere. + return undefined; + } + var generatedName = ts.getGeneratedNameForNode(node); + if (node.exportClause) { + var statements = []; + // export { x, y } from "mod"; + if (moduleKind !== ts.ModuleKind.AMD) { + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(generatedName, + /*type*/ undefined, createRequireCall(node)) + ]), + /*location*/ node)); + } + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.createStatement(createExportExpression(ts.getExportName(specifier), exportedValue), + /*location*/ specifier)); + } + return ts.singleOrMany(statements); + } + else { + // export * from "mod"; + return ts.createStatement(ts.createCall(ts.createIdentifier("__export"), + /*typeArguments*/ undefined, [ + moduleKind !== ts.ModuleKind.AMD + ? createRequireCall(node) + : generatedName + ]), + /*location*/ node); + } + } + /** + * Visits an ExportAssignment node. + * + * @param node The node to visit. + */ + function visitExportAssignment(node) { + if (node.isExportEquals) { + return undefined; + } + var statements; + var original = node.original; + if (original && hasAssociatedEndOfDeclarationMarker(original)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportStatement(deferredExports[id], ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + else { + statements = appendExportStatement(statements, ts.createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true); + } + return ts.singleOrMany(statements); + } + /** + * Visits a FunctionDeclaration node. + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createFunctionDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.parameters, + /*type*/ undefined, node.body, + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a ClassDeclaration node. + * + * @param node The node to visit. + */ + function visitClassDeclaration(node) { + var statements; + if (ts.hasModifier(node, 1 /* Export */)) { + statements = ts.append(statements, ts.setOriginalNode(ts.createClassDeclaration( + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + /*typeParameters*/ undefined, node.heritageClauses, node.members, + /*location*/ node), + /*original*/ node)); + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node); + } + else { + statements = appendExportsOfHoistedDeclaration(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Visits a VariableStatement node. + * + * @param node The node to visit. + */ + function visitVariableStatement(node) { + var statements; + var variables; + var expressions; + if (ts.hasModifier(node, 1 /* Export */)) { + var modifiers = void 0; + // If we're exporting these variables, then these just become assignments to 'exports.x'. + // We only want to emit assignments for variables with initializers. + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var variable = _a[_i]; + if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { + if (!modifiers) { + modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + } + variables = ts.append(variables, variable); + } + else if (variable.initializer) { + expressions = ts.append(expressions, transformInitializedVariable(variable)); + } + } + if (variables) { + statements = ts.append(statements, ts.updateVariableStatement(node, modifiers, ts.updateVariableDeclarationList(node.declarationList, variables))); + } + if (expressions) { + statements = ts.append(statements, ts.createStatement(ts.inlineExpressions(expressions), /*location*/ node)); + } + } + else { + statements = ts.append(statements, node); + } + if (hasAssociatedEndOfDeclarationMarker(node)) { + // Defer exports until we encounter an EndOfDeclarationMarker node + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node); + } + else { + statements = appendExportsOfVariableStatement(statements, node); + } + return ts.singleOrMany(statements); + } + /** + * Transforms an exported variable with an initializer into an expression. + * + * @param node The node to transform. + */ + function transformInitializedVariable(node) { + if (ts.isBindingPattern(node.name)) { + return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + } + else { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, + /*location*/ node.name), node.initializer); + } + } + /** + * Visits a MergeDeclarationMarker used as a placeholder for the beginning of a merged + * and transformed declaration. + * + * @param node The node to visit. + */ + function visitMergeDeclarationMarker(node) { + // For an EnumDeclaration or ModuleDeclaration that merges with a preceeding + // declaration we do not emit a leading variable declaration. To preserve the + // begin/end semantics of the declararation and to properly handle exports + // we wrapped the leading variable declaration in a `MergeDeclarationMarker`. + // + // To balance the declaration, add the exports of the elided variable + // statement. + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 204 /* VariableStatement */) { + var id = ts.getOriginalNodeId(node); + deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); + } + return node; + } + /** + * Determines whether a node has an associated EndOfDeclarationMarker. + * + * @param node The node to test. + */ + function hasAssociatedEndOfDeclarationMarker(node) { + return (ts.getEmitFlags(node) & 33554432 /* HasEndOfDeclarationMarker */) !== 0; + } + /** + * Visits a DeclarationMarker used as a placeholder for the end of a transformed + * declaration. + * + * @param node The node to visit. + */ + function visitEndOfDeclarationMarker(node) { + // For some transformations we emit an `EndOfDeclarationMarker` to mark the actual + // end of the transformed declaration. We use this marker to emit any deferred exports + // of the declaration. + var id = ts.getOriginalNodeId(node); + var statements = deferredExports[id]; + if (statements) { + delete deferredExports[id]; + return ts.append(statements, node); + } + return node; + } + /** + * Appends the exports of an ImportDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + var importClause = decl.importClause; + if (!importClause) { + return statements; + } + if (importClause.name) { + statements = appendExportsOfDeclaration(statements, importClause); + } + var namedBindings = importClause.namedBindings; + if (namedBindings) { + switch (namedBindings.kind) { + case 236 /* NamespaceImport */: + statements = appendExportsOfDeclaration(statements, namedBindings); + break; + case 237 /* NamedImports */: + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var importBinding = _a[_i]; + statements = appendExportsOfDeclaration(statements, importBinding); + } + break; + } + } + return statements; + } + /** + * Appends the exports of an ImportEqualsDeclaration to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfImportEqualsDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + return appendExportsOfDeclaration(statements, decl); + } + /** + * Appends the exports of a VariableStatement to a statement list, returning the statement + * list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param node The VariableStatement whose exports are to be recorded. + */ + function appendExportsOfVariableStatement(statements, node) { + if (currentModuleInfo.exportEquals) { + return statements; + } + for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + statements = appendExportsOfBindingElement(statements, decl); + } + return statements; + } + /** + * Appends the exports of a VariableDeclaration or BindingElement to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfBindingElement(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + statements = appendExportsOfBindingElement(statements, element); + } + } + } + else if (!ts.isGeneratedIdentifier(decl.name)) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a ClassDeclaration or FunctionDeclaration to a statement list, + * returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration whose exports are to be recorded. + */ + function appendExportsOfHoistedDeclaration(statements, decl) { + if (currentModuleInfo.exportEquals) { + return statements; + } + if (ts.hasModifier(decl, 1 /* Export */)) { + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); + } + if (decl.name) { + statements = appendExportsOfDeclaration(statements, decl); + } + return statements; + } + /** + * Appends the exports of a declaration to a statement list, returning the statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param decl The declaration to export. + */ + function appendExportsOfDeclaration(statements, decl) { + var name = ts.getDeclarationName(decl); + var exportSpecifiers = currentModuleInfo.exportSpecifiers[name.text]; + if (exportSpecifiers) { + for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) { + var exportSpecifier = exportSpecifiers_2[_i]; + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + } + } + return statements; + } + /** + * Appends the down-level representation of an export to a statement list, returning the + * statement list. + * + * @param statements A statement list to which the down-level export statements are to be + * appended. If `statements` is `undefined`, a new array is allocated if statements are + * appended. + * @param exportName The name of the export. + * @param expression The expression to export. + * @param location The location to use for source maps and comments for the export. + * @param allowComments Whether to allow comments on the export. + */ + function appendExportStatement(statements, exportName, expression, location, allowComments) { + if (exportName.text === "default") { + var sourceFile = ts.getOriginalNode(currentSourceFile, ts.isSourceFile); + if (sourceFile && !sourceFile.symbol.exports["___esModule"]) { + if (languageVersion === 0 /* ES3 */) { + statements = ts.append(statements, ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true)))); + } + else { + statements = ts.append(statements, ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral("__esModule"), + ts.createObjectLiteral([ + ts.createPropertyAssignment("value", ts.createLiteral(true)) + ]) + ]))); + } + } + } + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + return statements; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + * @param allowComments An optional value indicating whether to emit comments for the statement. + */ + function createExportStatement(name, value, location, allowComments) { + var statement = ts.createStatement(createExportExpression(name, value), location); + ts.startOnNewLine(statement); + if (!allowComments) { + ts.setEmitFlags(statement, 49152 /* NoComments */); + } + return statement; + } + /** + * Creates a call to the current file's export function to export a value. + * + * @param name The bound name of the export. + * @param value The exported value. + * @param location The location to use for source maps and comments for the export. + */ + function createExportExpression(name, value, location) { + return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value, location); + } + // + // Modifier Visitors + // + /** + * Visit nodes to elide module-specific modifiers. + * + * @param node The node to visit. + */ + function modifierVisitor(node) { + // Elide module-specific modifiers. + switch (node.kind) { + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: + return undefined; + } + return node; + } + // + // Emit Notification + // + /** + * Hook for node emit notifications. + * + * @param emitContext A context hint for the emitter. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(emitContext, node, emitCallback) { + if (node.kind === 260 /* SourceFile */) { + currentSourceFile = node; + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; + noSubstitution = ts.createMap(); + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + currentModuleInfo = undefined; + noSubstitution = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + // + // Substitutions + // + /** + * Hooks node substitutions. + * + * @param emitContext A context hint for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (node.id && noSubstitution[node.id]) { + return node; + } + if (emitContext === 1 /* Expression */) { + return substituteExpression(node); + } + else if (ts.isShorthandPropertyAssignment(node)) { + return substituteShorthandPropertyAssignment(node); + } + return node; + } + /** + * Substitution for a ShorthandPropertyAssignment whose declaration name is an imported + * or exported symbol. + * + * @param node The node to substitute. + */ + function substituteShorthandPropertyAssignment(node) { + var name = node.name; + var exportedOrImportedName = substituteExpressionIdentifier(name); + if (exportedOrImportedName !== name) { + // A shorthand property with an assignment initializer is probably part of a + // destructuring assignment + if (node.objectAssignmentInitializer) { + var initializer = ts.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer); + return ts.createPropertyAssignment(name, initializer, /*location*/ node); + } + return ts.createPropertyAssignment(name, exportedOrImportedName, /*location*/ node); + } + return node; + } + /** + * Substitution for an Expression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteExpression(node) { + switch (node.kind) { + case 70 /* Identifier */: + return substituteExpressionIdentifier(node); + case 191 /* BinaryExpression */: + return substituteBinaryExpression(node); + case 190 /* PostfixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: + return substituteUnaryExpression(node); + } + return node; + } + /** + * Substitution for an Identifier expression that may contain an imported or exported + * symbol. + * + * @param node The node to substitute. + */ + function substituteExpressionIdentifier(node) { + if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { + var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); + if (exportContainer && exportContainer.kind === 260 /* SourceFile */) { + return ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node), + /*location*/ node); + } + var importDeclaration = resolver.getReferencedImportDeclaration(node); + if (importDeclaration) { + if (ts.isImportClause(importDeclaration)) { + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), + /*location*/ node); + } + else if (ts.isImportSpecifier(importDeclaration)) { + var name_36 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_36), + /*location*/ node); + } + } + } + return node; + } + /** + * Substitution for a BinaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteBinaryExpression(node) { + // When we see an assignment expression whose left-hand side is an exported symbol, + // we should ensure all exports of that symbol are updated with the correct value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if (ts.isAssignmentOperator(node.operatorToken.kind) + && ts.isIdentifier(node.left) + && !ts.isGeneratedIdentifier(node.left) + && !ts.isLocalName(node.left) + && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) { + var exportedNames = getExports(node.left); + if (exportedNames) { + // For each additional export of the declaration, apply an export assignment. + var expression = node; + for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { + var exportName = exportedNames_3[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression, /*location*/ node); + } + return expression; + } + } + return node; + } + /** + * Substitution for a UnaryExpression that may contain an imported or exported symbol. + * + * @param node The node to substitute. + */ + function substituteUnaryExpression(node) { + // When we see a prefix or postfix increment expression whose operand is an exported + // symbol, we should ensure all exports of that symbol are updated with the correct + // value. + // + // - We do not substitute generated identifiers for any reason. + // - We do not substitute identifiers tagged with the LocalName flag. + // - We do not substitute identifiers that were originally the name of an enum or + // namespace due to how they are transformed in TypeScript. + // - We only substitute identifiers that are exported at the top level. + if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + && ts.isIdentifier(node.operand) + && !ts.isGeneratedIdentifier(node.operand) + && !ts.isLocalName(node.operand) + && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { + var exportedNames = getExports(node.operand); + if (exportedNames) { + var expression = node.kind === 190 /* PostfixUnaryExpression */ + ? ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1), + /*location*/ node) + : node; + for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { + var exportName = exportedNames_4[_i]; + // Mark the node to prevent triggering this rule again. + noSubstitution[ts.getNodeId(expression)] = true; + expression = createExportExpression(exportName, expression); + } + return expression; + } + } + return node; + } + /** + * Gets the additional exports of a name. + * + * @param name The name. + */ + function getExports(name) { + if (!ts.isGeneratedIdentifier(name)) { + var valueDeclaration = resolver.getReferencedImportDeclaration(name) + || resolver.getReferencedValueDeclaration(name); + if (valueDeclaration) { + return currentModuleInfo + && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]; + } + } + } + var _a; + } + ts.transformModule = transformModule; +})(ts || (ts = {})); /// /// /// +/// /// /// /// @@ -53978,10 +55767,12 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; transformers.push(ts.transformTypeScript); - transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); } + if (languageVersion < 5 /* ESNext */) { + transformers.push(ts.transformESNext); + } if (languageVersion < 4 /* ES2017 */) { transformers.push(ts.transformES2017); } @@ -53992,6 +55783,9 @@ var ts; transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } + transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ts.ModuleKind.None]); + // The ES5 transformer is last so that it can substitute expressions like `exports.default` + // for ES3. if (languageVersion < 1 /* ES5 */) { transformers.push(ts.transformES5); } @@ -54009,7 +55803,7 @@ var ts; function transformFiles(resolver, host, sourceFiles, transformers) { var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(289 /* Count */); + var enabledSyntaxKindFeatures = new Array(295 /* Count */); var lexicalEnvironmentStackOffset = 0; var hoistedVariableDeclarations; var hoistedFunctionDeclarations; @@ -54409,7 +56203,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 291 /* NotEmittedStatement */ && (emitFlags & 512 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -54422,7 +56216,7 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 287 /* NotEmittedStatement */ + if (node.kind !== 291 /* NotEmittedStatement */ && (emitFlags & 1024 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -54601,7 +56395,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 287 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 291 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 16384 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 32768 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -54620,7 +56414,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 === 220 /* VariableDeclarationList */) { + if (node.kind === 223 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -54930,7 +56724,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 231 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 234 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -55004,10 +56798,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 219 /* VariableDeclaration */) { + if (declaration.kind === 222 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 234 /* NamedImports */ || declaration.kind === 235 /* ImportSpecifier */ || declaration.kind === 232 /* ImportClause */) { + else if (declaration.kind === 237 /* NamedImports */ || declaration.kind === 238 /* ImportSpecifier */ || declaration.kind === 235 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -55025,7 +56819,7 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 231 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 234 /* ImportDeclaration */) { // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; @@ -55035,12 +56829,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 229 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 226 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 229 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -55158,43 +56952,47 @@ var ts; function emitType(type) { switch (type.kind) { case 118 /* AnyKeyword */: - case 133 /* StringKeyword */: - case 131 /* NumberKeyword */: + case 134 /* StringKeyword */: + case 132 /* NumberKeyword */: case 121 /* BooleanKeyword */: - case 134 /* SymbolKeyword */: + case 135 /* SymbolKeyword */: case 104 /* VoidKeyword */: - case 136 /* UndefinedKeyword */: + case 137 /* UndefinedKeyword */: case 94 /* NullKeyword */: - case 128 /* NeverKeyword */: - case 166 /* ThisType */: - case 167 /* LiteralType */: + case 129 /* NeverKeyword */: + case 167 /* ThisType */: + case 170 /* LiteralType */: return writeTextOfNode(currentText, type); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return emitTypeReference(type); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return emitTypeQuery(type); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return emitArrayType(type); - case 162 /* TupleType */: + case 163 /* TupleType */: return emitTupleType(type); - case 163 /* UnionType */: + case 164 /* UnionType */: return emitUnionType(type); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return emitIntersectionType(type); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return emitParenType(type); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 168 /* TypeOperator */: + return emitTypeOperator(type); + case 169 /* IndexedAccessType */: + return emitPropertyAccessType(type); + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return emitTypeLiteral(type); case 70 /* Identifier */: return emitEntityName(type); - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return emitEntityName(type); - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { @@ -55202,8 +57000,8 @@ var ts; writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 140 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 140 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 141 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 141 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -55212,14 +57010,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 230 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 233 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 173 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 176 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -55265,6 +57063,17 @@ var ts; emitType(type.type); write(")"); } + function emitTypeOperator(type) { + write(ts.tokenToString(type.operator)); + write(" "); + emitType(type.type); + } + function emitPropertyAccessType(node) { + emitType(node.objectType); + write("["); + emitType(node.indexType); + write("]"); + } function emitTypeLiteral(type) { write("{"); if (type.members.length) { @@ -55298,9 +57107,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_37 = baseName + "_" + count; + if (!(name_37 in currentIdentifiers)) { + return name_37; } } } @@ -55347,10 +57156,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 230 /* ImportEqualsDeclaration */ || - (node.parent.kind === 256 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 233 /* ImportEqualsDeclaration */ || + (node.parent.kind === 260 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 256 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 260 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -55360,7 +57169,7 @@ var ts; }); } else { - if (node.kind === 231 /* ImportDeclaration */) { + if (node.kind === 234 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -55378,23 +57187,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return writeVariableStatement(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return writeClassDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -55402,7 +57211,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 256 /* SourceFile */) { + if (node.parent.kind === 260 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -55411,7 +57220,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 223 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 226 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -55463,7 +57272,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 236 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -55487,7 +57296,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 236 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -55508,13 +57317,13 @@ var ts; // the only case when it is not true is when we call it to emit correct name for module augmentation - d.ts files with just module augmentations are not considered // external modules since they are indistinguishable from script files with ambient modules. To fix this in such d.ts files we'll emit top level 'export {}' // so compiler will treat them as external modules. - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 226 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 229 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 230 /* ImportEqualsDeclaration */) { + if (parent.kind === 233 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 226 /* ModuleDeclaration */) { + else if (parent.kind === 229 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -55584,7 +57393,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 227 /* ModuleBlock */) { + while (node.body && node.body.kind !== 230 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -55654,7 +57463,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 148 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 149 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -55665,15 +57474,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 160 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 148 /* MethodDeclaration */ || - node.parent.kind === 147 /* MethodSignature */ || - node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - node.parent.kind === 152 /* CallSignature */ || - node.parent.kind === 153 /* ConstructSignature */); + if (node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 161 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 149 /* MethodDeclaration */ || + node.parent.kind === 148 /* MethodSignature */ || + node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + node.parent.kind === 153 /* CallSignature */ || + node.parent.kind === 154 /* ConstructSignature */); emitType(node.constraint); } else { @@ -55684,31 +57493,31 @@ 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 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 152 /* CallSignature */: + case 153 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(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 === 222 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 225 /* 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 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -55746,7 +57555,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 222 /* ClassDeclaration */) { + if (node.parent.parent.kind === 225 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -55830,7 +57639,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 219 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 222 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -55841,11 +57650,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */ || - (node.kind === 143 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */ || + (node.kind === 144 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) && node.parent.kind === 160 /* TypeLiteral */) { + if ((node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) && node.parent.kind === 161 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -55858,14 +57667,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 219 /* VariableDeclaration */) { + if (node.kind === 222 /* VariableDeclaration */) { 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 : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 146 /* PropertyDeclaration */ || node.kind === 145 /* PropertySignature */) { + else if (node.kind === 147 /* PropertyDeclaration */ || node.kind === 146 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -55874,7 +57683,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 === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* 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 : @@ -55906,7 +57715,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 194 /* OmittedExpression */) { + if (element.kind !== 197 /* OmittedExpression */) { elements.push(element); } } @@ -55976,7 +57785,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 150 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 151 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -55989,7 +57798,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 150 /* GetAccessor */ + return accessor.kind === 151 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -55998,7 +57807,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 151 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 152 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -56048,17 +57857,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 221 /* FunctionDeclaration */) { + if (node.kind === 224 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 148 /* MethodDeclaration */ || node.kind === 149 /* Constructor */) { + else if (node.kind === 149 /* MethodDeclaration */ || node.kind === 150 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 221 /* FunctionDeclaration */) { + if (node.kind === 224 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 149 /* Constructor */) { + else if (node.kind === 150 /* Constructor */) { write("constructor"); } else { @@ -56078,17 +57887,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 153 /* ConstructSignature */ || node.kind === 158 /* ConstructorType */) { + if (node.kind === 154 /* ConstructSignature */ || node.kind === 159 /* ConstructorType */) { write("new "); } - else if (node.kind === 157 /* FunctionType */) { + else if (node.kind === 158 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -56103,22 +57912,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 154 /* IndexSignature */) { + if (node.kind === 155 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 157 /* FunctionType */ || node.kind === 158 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 160 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 158 /* FunctionType */ || node.kind === 159 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 161 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 149 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 150 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -56132,26 +57941,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 153 /* ConstructSignature */: + case 154 /* 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 152 /* CallSignature */: + case 153 /* 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 154 /* IndexSignature */: + case 155 /* 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 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -56159,7 +57968,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 === 222 /* ClassDeclaration */) { + else if (node.parent.kind === 225 /* 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 : @@ -56173,7 +57982,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 221 /* FunctionDeclaration */: + case 224 /* 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 : @@ -56208,9 +58017,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 157 /* FunctionType */ || - node.parent.kind === 158 /* ConstructorType */ || - node.parent.parent.kind === 160 /* TypeLiteral */) { + if (node.parent.kind === 158 /* FunctionType */ || + node.parent.kind === 159 /* ConstructorType */ || + node.parent.parent.kind === 161 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -56226,24 +58035,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 149 /* Constructor */: + case 150 /* 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 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: // 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 152 /* CallSignature */: + case 153 /* 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 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -56251,7 +58060,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 === 222 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 225 /* 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 : @@ -56264,7 +58073,7 @@ 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 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: 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 : @@ -56276,12 +58085,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 168 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 171 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 169 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 172 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -56292,7 +58101,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 194 /* OmittedExpression */) { + if (bindingElement.kind === 197 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -56301,7 +58110,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 170 /* BindingElement */) { + else if (bindingElement.kind === 173 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -56340,40 +58149,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 226 /* ModuleDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 223 /* InterfaceDeclaration */: - case 222 /* ClassDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: + case 224 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 226 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return emitExportDeclaration(node); - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return writeFunctionDeclaration(node); - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 154 /* IndexSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 155 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return emitAccessorDeclaration(node); - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return emitPropertyDeclaration(node); - case 255 /* EnumMember */: + case 259 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* SourceFile */: + case 260 /* SourceFile */: return emitSourceFile(node); } } @@ -56464,6 +58273,7 @@ var ts; // This is typically used for JSX spread attributes, // and can be used for object literal spread properties. var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; + var restHelper = "\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && !e.indexOf(p))\n t[p] = s[p];\n return t;\n};"; // emit output for the __decorate helper function var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; // emit output for the __metadata helper function @@ -56561,6 +58371,7 @@ var ts; var currentFileIdentifiers; var extendsEmitted; var assignEmitted; + var restEmitted; var decorateEmitted; var paramEmitted; var awaiterEmitted; @@ -56754,7 +58565,7 @@ var ts; var kind = node.kind; switch (kind) { // Top-level nodes - case 256 /* SourceFile */: + case 260 /* SourceFile */: return emitSourceFile(node); } } @@ -56810,210 +58621,216 @@ var ts; case 123 /* DeclareKeyword */: case 124 /* GetKeyword */: case 125 /* IsKeyword */: - case 126 /* ModuleKeyword */: - case 127 /* NamespaceKeyword */: - case 128 /* NeverKeyword */: - case 129 /* ReadonlyKeyword */: - case 130 /* RequireKeyword */: - case 131 /* NumberKeyword */: - case 132 /* SetKeyword */: - case 133 /* StringKeyword */: - case 134 /* SymbolKeyword */: - case 135 /* TypeKeyword */: - case 136 /* UndefinedKeyword */: - case 137 /* FromKeyword */: - case 138 /* GlobalKeyword */: - case 139 /* OfKeyword */: + case 127 /* ModuleKeyword */: + case 128 /* NamespaceKeyword */: + case 129 /* NeverKeyword */: + case 130 /* ReadonlyKeyword */: + case 131 /* RequireKeyword */: + case 132 /* NumberKeyword */: + case 133 /* SetKeyword */: + case 134 /* StringKeyword */: + case 135 /* SymbolKeyword */: + case 136 /* TypeKeyword */: + case 137 /* UndefinedKeyword */: + case 138 /* FromKeyword */: + case 139 /* GlobalKeyword */: + case 140 /* OfKeyword */: writeTokenText(kind); return; // Parse tree nodes // Names - case 140 /* QualifiedName */: + case 141 /* QualifiedName */: return emitQualifiedName(node); - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: return emitTypeParameter(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return emitParameter(node); - case 144 /* Decorator */: + case 145 /* Decorator */: return emitDecorator(node); // Type members - case 145 /* PropertySignature */: + case 146 /* PropertySignature */: return emitPropertySignature(node); - case 146 /* PropertyDeclaration */: + case 147 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 147 /* MethodSignature */: + case 148 /* MethodSignature */: return emitMethodSignature(node); - case 148 /* MethodDeclaration */: + case 149 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return emitConstructor(node); - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return emitAccessorDeclaration(node); - case 152 /* CallSignature */: + case 153 /* CallSignature */: return emitCallSignature(node); - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: return emitConstructSignature(node); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return emitIndexSignature(node); // Types - case 155 /* TypePredicate */: + case 156 /* TypePredicate */: return emitTypePredicate(node); - case 156 /* TypeReference */: + case 157 /* TypeReference */: return emitTypeReference(node); - case 157 /* FunctionType */: + case 158 /* FunctionType */: return emitFunctionType(node); - case 158 /* ConstructorType */: + case 159 /* ConstructorType */: return emitConstructorType(node); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return emitTypeQuery(node); - case 160 /* TypeLiteral */: + case 161 /* TypeLiteral */: return emitTypeLiteral(node); - case 161 /* ArrayType */: + case 162 /* ArrayType */: return emitArrayType(node); - case 162 /* TupleType */: + case 163 /* TupleType */: return emitTupleType(node); - case 163 /* UnionType */: + case 164 /* UnionType */: return emitUnionType(node); - case 164 /* IntersectionType */: + case 165 /* IntersectionType */: return emitIntersectionType(node); - case 165 /* ParenthesizedType */: + case 166 /* ParenthesizedType */: return emitParenthesizedType(node); - case 195 /* ExpressionWithTypeArguments */: + case 198 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 166 /* ThisType */: + case 167 /* ThisType */: return emitThisType(); - case 167 /* LiteralType */: + case 168 /* TypeOperator */: + return emitTypeOperator(node); + case 169 /* IndexedAccessType */: + return emitPropertyAccessType(node); + case 170 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 168 /* ObjectBindingPattern */: + case 171 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 169 /* ArrayBindingPattern */: + case 172 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return emitBindingElement(node); // Misc - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return emitTemplateSpan(node); - case 199 /* SemicolonClassElement */: + case 202 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 200 /* Block */: + case 203 /* Block */: return emitBlock(node); - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: return emitVariableStatement(node); - case 202 /* EmptyStatement */: + case 205 /* EmptyStatement */: return emitEmptyStatement(); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return emitExpressionStatement(node); - case 204 /* IfStatement */: + case 207 /* IfStatement */: return emitIfStatement(node); - case 205 /* DoStatement */: + case 208 /* DoStatement */: return emitDoStatement(node); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: return emitWhileStatement(node); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return emitForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return emitForInStatement(node); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: return emitForOfStatement(node); - case 210 /* ContinueStatement */: + case 213 /* ContinueStatement */: return emitContinueStatement(node); - case 211 /* BreakStatement */: + case 214 /* BreakStatement */: return emitBreakStatement(node); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: return emitReturnStatement(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: return emitWithStatement(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return emitSwitchStatement(node); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: return emitLabeledStatement(node); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: return emitThrowStatement(node); - case 217 /* TryStatement */: + case 220 /* TryStatement */: return emitTryStatement(node); - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 220 /* VariableDeclarationList */: + case 223 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 221 /* FunctionDeclaration */: + case 224 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: return emitClassDeclaration(node); - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return emitModuleBlock(node); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return emitCaseBlock(node); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: return emitImportDeclaration(node); - case 232 /* ImportClause */: + case 235 /* ImportClause */: return emitImportClause(node); - case 233 /* NamespaceImport */: + case 236 /* NamespaceImport */: return emitNamespaceImport(node); - case 234 /* NamedImports */: + case 237 /* NamedImports */: return emitNamedImports(node); - case 235 /* ImportSpecifier */: + case 238 /* ImportSpecifier */: return emitImportSpecifier(node); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: return emitExportAssignment(node); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: return emitExportDeclaration(node); - case 238 /* NamedExports */: + case 241 /* NamedExports */: return emitNamedExports(node); - case 239 /* ExportSpecifier */: + case 242 /* ExportSpecifier */: return emitExportSpecifier(node); - case 240 /* MissingDeclaration */: + case 243 /* MissingDeclaration */: return; // Module references - case 241 /* ExternalModuleReference */: + case 244 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: return emitJsxAttribute(node); - case 247 /* JsxSpreadAttribute */: + case 250 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 248 /* JsxExpression */: + case 251 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 249 /* CaseClause */: + case 252 /* CaseClause */: return emitCaseClause(node); - case 250 /* DefaultClause */: + case 253 /* DefaultClause */: return emitDefaultClause(node); - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: return emitHeritageClause(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 253 /* PropertyAssignment */: + case 256 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 254 /* ShorthandPropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); + case 258 /* SpreadAssignment */: + return emitSpreadAssignment(node); // Enum - case 255 /* EnumMember */: + case 259 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with @@ -57050,65 +58867,65 @@ var ts; writeTokenText(kind); return; // Expressions - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 173 /* PropertyAccessExpression */: + case 176 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 175 /* CallExpression */: + case 178 /* CallExpression */: return emitCallExpression(node); - case 176 /* NewExpression */: + case 179 /* NewExpression */: return emitNewExpression(node); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 178 /* TypeAssertionExpression */: + case 181 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 179 /* ParenthesizedExpression */: + case 182 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 180 /* FunctionExpression */: + case 183 /* FunctionExpression */: return emitFunctionExpression(node); - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: return emitArrowFunction(node); - case 182 /* DeleteExpression */: + case 185 /* DeleteExpression */: return emitDeleteExpression(node); - case 183 /* TypeOfExpression */: + case 186 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 184 /* VoidExpression */: + case 187 /* VoidExpression */: return emitVoidExpression(node); - case 185 /* AwaitExpression */: + case 188 /* AwaitExpression */: return emitAwaitExpression(node); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 187 /* PostfixUnaryExpression */: + case 190 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return emitBinaryExpression(node); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return emitConditionalExpression(node); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: return emitTemplateExpression(node); - case 191 /* YieldExpression */: + case 194 /* YieldExpression */: return emitYieldExpression(node); - case 192 /* SpreadElementExpression */: - return emitSpreadElementExpression(node); - case 193 /* ClassExpression */: + case 195 /* SpreadElement */: + return emitSpreadExpression(node); + case 196 /* ClassExpression */: return emitClassExpression(node); - case 194 /* OmittedExpression */: + case 197 /* OmittedExpression */: return; - case 196 /* AsExpression */: + case 199 /* AsExpression */: return emitAsExpression(node); - case 197 /* NonNullExpression */: + case 200 /* NonNullExpression */: return emitNonNullExpression(node); // JSX - case 242 /* JsxElement */: + case 245 /* JsxElement */: return emitJsxElement(node); - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 288 /* PartiallyEmittedExpression */: + case 292 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } @@ -57234,7 +59051,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 150 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 151 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -57322,6 +59139,17 @@ var ts; function emitThisType() { write("this"); } + function emitTypeOperator(node) { + writeTokenText(node.operator); + write(" "); + emit(node.type); + } + function emitPropertyAccessType(node) { + emit(node.objectType); + write("["); + emit(node.indexType); + write("]"); + } function emitLiteralType(node) { emitExpression(node.literal); } @@ -57508,7 +59336,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 === 186 /* PrefixUnaryExpression */ + return operand.kind === 189 /* PrefixUnaryExpression */ && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); } @@ -57552,7 +59380,7 @@ var ts; write(node.asteriskToken ? "yield*" : "yield"); emitExpressionWithPrefix(" ", node.expression); } - function emitSpreadElementExpression(node) { + function emitSpreadExpression(node) { write("..."); emitExpression(node.expression); } @@ -57626,7 +59454,7 @@ var ts; if (node.elseStatement) { writeLine(); writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 204 /* IfStatement */) { + if (node.elseStatement.kind === 207 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -57688,7 +59516,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 220 /* VariableDeclarationList */) { + if (node.kind === 223 /* VariableDeclarationList */) { emit(node); } else { @@ -57927,7 +59755,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 226 /* ModuleDeclaration */) { + while (body.kind === 229 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -58167,6 +59995,12 @@ var ts; emitExpression(node.objectAssignmentInitializer); } } + function emitSpreadAssignment(node) { + if (node.expression) { + write("..."); + emitExpression(node.expression); + } + } // // Enum // @@ -58252,10 +60086,17 @@ var ts; extendsEmitted = true; helpersEmitted = true; } - if (compilerOptions.jsx !== 1 /* Preserve */ && !assignEmitted && (node.flags & 16384 /* HasJsxSpreadAttributes */)) { + if ((languageVersion < 5 /* ESNext */ || currentSourceFile.scriptKind === 2 /* JSX */ || currentSourceFile.scriptKind === 4 /* TSX */) && + compilerOptions.jsx !== 1 /* Preserve */ && + !assignEmitted && + node.flags & 16384 /* HasSpreadAttribute */) { writeLines(assignHelper); assignEmitted = true; } + if (languageVersion < 5 /* ESNext */ && !restEmitted && node.flags & 32768 /* HasRestAttribute */) { + writeLines(restHelper); + restEmitted = true; + } if (!decorateEmitted && node.flags & 2048 /* HasDecorators */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { @@ -58601,7 +60442,7 @@ var ts; && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 179 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 182 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -58664,10 +60505,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_38 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_38)) { tempFlags |= flags; - return name_41; + return name_38; } } while (true) { @@ -58675,11 +60516,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_39 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_39)) { + return name_39; } } } @@ -58728,17 +60569,17 @@ var ts; switch (node.kind) { case 70 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 231 /* ImportDeclaration */: - case 237 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: + case 240 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 221 /* FunctionDeclaration */: - case 222 /* ClassDeclaration */: - case 236 /* ExportAssignment */: + case 224 /* FunctionDeclaration */: + case 225 /* ClassDeclaration */: + case 239 /* ExportAssignment */: return generateNameForExportDefault(); - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: return generateNameForClassExpression(); default: return makeTempVariableName(0 /* Auto */); @@ -58905,7 +60746,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.2"; + ts.version = "2.1.3"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -59131,11 +60972,11 @@ var ts; } var resolutions = []; var cache = ts.createMap(); - for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_43 = names_2[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name_40 = names_1[_i]; + var result = name_40 in cache + ? cache[name_40] + : cache[name_40] = loader(name_40, containingFile); resolutions.push(result); } return resolutions; @@ -59156,7 +60997,7 @@ var ts; // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module. // As all these operations happen - and are nested - within the createProgram call, they close over the below variables. // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses. - var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; + var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; var currentNodeModulesDepth = 0; // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed. @@ -59173,7 +61014,15 @@ var ts; var hasEmitBlockingDiagnostics = ts.createFileMap(getCanonicalFileName); var resolveModuleNamesWorker; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }; + resolveModuleNamesWorker = function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile).map(function (resolved) { + // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. + if (!resolved || resolved.extension !== undefined) { + return resolved; + } + var withExtension = ts.clone(resolved); + withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); + return withExtension; + }); }; } else { var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }; @@ -59246,6 +61095,7 @@ var ts; getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker }; verifyCompilerOptions(); @@ -59282,6 +61132,112 @@ var ts; } return classifiableNames; } + function resolveModuleNamesReusingOldState(moduleNames, containingFile, file, oldProgramState) { + if (!oldProgramState && !file.ambientModuleNames.length) { + // if old program state is not supplied and file does not contain locally defined ambient modules + // then the best we can do is fallback to the default logic + return resolveModuleNamesWorker(moduleNames, containingFile); + } + // at this point we know that either + // - file has local declarations for ambient modules + // OR + // - old program state is available + // OR + // - both of items above + // With this it is possible that we can tell how some module names from the initial list will be resolved + // without doing actual resolution (in particular if some name was resolved to ambient module). + // Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker` + // since we don't want to resolve them again. + // this is a list of modules for which we cannot predict resolution so they should be actually resolved + var unknownModuleNames; + // this is a list of combined results assembles from predicted and resolved results. + // Order in this list matches the order in the original list of module names `moduleNames` which is important + // so later we can split results to resolutions of modules and resolutions of module augmentations. + var result; + // a transient placeholder that is used to mark predicted resolution in the result list + var predictedToResolveToAmbientModuleMarker = {}; + for (var i = 0; i < moduleNames.length; i++) { + var moduleName = moduleNames[i]; + // module name is known to be resolved to ambient module if + // - module name is contained in the list of ambient modules that are locally declared in the file + // - in the old program module name was resolved to ambient module whose declaration is in non-modified file + // (so the same module declaration will land in the new program) + var isKnownToResolveToAmbientModule = false; + if (ts.contains(file.ambientModuleNames, moduleName)) { + isKnownToResolveToAmbientModule = 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); + } + } + else { + isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + } + if (isKnownToResolveToAmbientModule) { + if (!unknownModuleNames) { + // found a first module name for which result can be prediced + // this means that this module name should not be passed to `resolveModuleNamesWorker`. + // We'll use a separate list for module names that are definitely unknown. + result = new Array(moduleNames.length); + // copy all module names that appear before the current one in the list + // since they are known to be unknown + unknownModuleNames = moduleNames.slice(0, i); + } + // mark prediced resolution in the result list + result[i] = predictedToResolveToAmbientModuleMarker; + } + else if (unknownModuleNames) { + // found unknown module name and we are already using separate list for those - add it to the list + unknownModuleNames.push(moduleName); + } + } + if (!unknownModuleNames) { + // we've looked throught the list but have not seen any predicted resolution + // use default logic + return resolveModuleNamesWorker(moduleNames, containingFile); + } + var resolutions = unknownModuleNames.length + ? resolveModuleNamesWorker(unknownModuleNames, containingFile) + : emptyArray; + // combine results of resolutions and predicted results + var j = 0; + for (var i = 0; i < result.length; i++) { + if (result[i] == predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } + else { + result[i] = resolutions[j]; + j++; + } + } + ts.Debug.assert(j === resolutions.length); + return result; + function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { + if (!oldProgramState) { + return false; + } + var resolutionToFile = ts.getResolvedModule(oldProgramState.file, moduleName); + if (resolutionToFile) { + // module used to be resolved to file - ignore it + return false; + } + var ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + if (!(ambientModule && ambientModule.declarations)) { + return false; + } + // at least one of declarations should come from non-modified source file + var firstUnmodifiedFile = ts.forEach(ambientModule.declarations, function (d) { + var f = ts.getSourceFileOfNode(d); + return !ts.contains(oldProgramState.modifiedFilePaths, f.path) && f; + }); + if (!firstUnmodifiedFile) { + return false; + } + if (ts.isTraceEnabled(options, host)) { + ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, firstUnmodifiedFile.fileName); + } + return true; + } + } function tryReuseStructureFromOldProgram() { if (!oldProgram) { return false; @@ -59340,29 +61296,8 @@ var ts; // 'types' references has changed return false; } - var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - if (resolveTypeReferenceDirectiveNamesWorker) { - var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); - // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { - return false; - } - } - // pass the cache of module/types resolutions from the old source file - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; - modifiedSourceFiles.push(newSourceFile); + // tentatively approve the file + modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else { // file has no changes - use it as is @@ -59371,15 +61306,42 @@ var ts; // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } + var modifiedFilePaths = modifiedSourceFiles.map(function (f) { return f.newFile.path; }); + // try to verify results of module resolution + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var _c = modifiedSourceFiles_1[_b], oldSourceFile = _c.oldFile, newSourceFile = _c.newFile; + var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); + if (resolveModuleNamesWorker) { + var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths: modifiedFilePaths }); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + if (resolveTypeReferenceDirectiveNamesWorker) { + var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (x) { return x.fileName; }); + var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath); + // ensure that types resolutions are still correct + var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged) { + return false; + } + } + // pass the cache of module/types resolutions from the old source file + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { - var modifiedFile = modifiedSourceFiles_1[_b]; - fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); + for (var _d = 0, modifiedSourceFiles_2 = modifiedSourceFiles; _d < modifiedSourceFiles_2.length; _d++) { + var modifiedFile = modifiedSourceFiles_2[_d]; + fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); oldProgram.structureIsReused = true; @@ -59395,11 +61357,14 @@ var ts; getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: function (file) { return !!sourceFilesFoundSearchingNodeModules[file.path]; }, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, }; } + function isSourceFileFromExternalLibrary(file) { + return sourceFilesFoundSearchingNodeModules[file.path]; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } @@ -59488,6 +61453,14 @@ var ts; } } function getSyntacticDiagnosticsForFile(sourceFile) { + // For JavaScript files, we report semantic errors for using TypeScript-only + // constructs from within a JavaScript file as syntactic errors. + if (ts.isSourceFileJavaScript(sourceFile)) { + if (!sourceFile.additionalSyntacticDiagnostics) { + sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile); + } + return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics); + } return sourceFile.parseDiagnostics; } function runWithCancellationToken(func) { @@ -59516,179 +61489,180 @@ var ts; var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report the normal typescript semantic errors. - // Instead, we just report errors for using TypeScript-only constructs from within a - // JavaScript file. - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? - getJavaScriptSemanticDiagnosticsForFile(sourceFile) : - typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report semantic errors. + // Instead, we'll report errors for using TypeScript-only constructs from within a + // JavaScript file when we get syntactic diagnostics for the file. + var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); }); } - function getJavaScriptSemanticDiagnosticsForFile(sourceFile) { + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; + var parent = sourceFile; walk(sourceFile); return diagnostics; function walk(node) { - if (!node) { - return false; + // 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 144 /* Parameter */: + case 147 /* PropertyDeclaration */: + if (parent.questionToken === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); + return; + } + // Pass through + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 222 /* VariableDeclaration */: + // type annotation + if (parent.type === node) { + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); + return; + } } switch (node.kind) { - case 230 /* ImportEqualsDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); - return true; - case 236 /* ExportAssignment */: + case 233 /* ImportEqualsDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); + return; + case 239 /* ExportAssignment */: if (node.isExportEquals) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); - return true; + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); + return; } break; - case 222 /* ClassDeclaration */: - var classDeclaration = node; - if (checkModifiers(classDeclaration.modifiers) || - checkTypeParameters(classDeclaration.typeParameters)) { - return true; - } - break; - case 251 /* HeritageClause */: + case 254 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 107 /* ImplementsKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); - return true; + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); + return; } break; - case 223 /* InterfaceDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 226 /* ModuleDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 224 /* TypeAliasDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); - return true; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - var functionDeclaration = node; - if (checkModifiers(functionDeclaration.modifiers) || - checkTypeParameters(functionDeclaration.typeParameters) || - checkTypeAnnotation(functionDeclaration.type)) { - return true; + case 226 /* InterfaceDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); + return; + case 229 /* ModuleDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); + return; + case 227 /* TypeAliasDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); + return; + case 228 /* EnumDeclaration */: + diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); + return; + case 181 /* TypeAssertionExpression */: + var typeAssertionExpression = node; + diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); + return; + } + var prevParent = parent; + parent = node; + ts.forEachChild(node, walk, walkArray); + parent = prevParent; + } + function walkArray(nodes) { + if (parent.decorators === nodes && !options.experimentalDecorators) { + 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_to_remove_this_warning)); + } + switch (parent.kind) { + case 225 /* ClassDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + // Check type parameters + if (nodes === parent.typeParameters) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); + return; + } + // pass through + case 204 /* VariableStatement */: + // Check modifiers + if (nodes === parent.modifiers) { + return checkModifiers(nodes, parent.kind === 204 /* VariableStatement */); } break; - case 201 /* VariableStatement */: - var variableStatement = node; - if (checkModifiers(variableStatement.modifiers)) { - return true; - } - break; - case 219 /* VariableDeclaration */: - var variableDeclaration = node; - if (checkTypeAnnotation(variableDeclaration.type)) { - return true; - } - break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: - var expression = node; - if (expression.typeArguments && expression.typeArguments.length > 0) { - var start = expression.typeArguments.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, expression.typeArguments.end - start, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 143 /* Parameter */: - var parameter = node; - if (parameter.modifiers) { - var start = parameter.modifiers.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, parameter.modifiers.end - start, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); - return true; - } - if (parameter.questionToken) { - diagnostics.push(ts.createDiagnosticForNode(parameter.questionToken, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); - return true; - } - if (parameter.type) { - diagnostics.push(ts.createDiagnosticForNode(parameter.type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - break; - case 146 /* PropertyDeclaration */: - var propertyDeclaration = node; - if (propertyDeclaration.modifiers) { - for (var _i = 0, _a = propertyDeclaration.modifiers; _i < _a.length; _i++) { + case 147 /* PropertyDeclaration */: + // Check modifiers of property declaration + if (nodes === parent.modifiers) { + for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 114 /* StaticKeyword */) { - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } - } - if (checkTypeAnnotation(node.type)) { - return true; + return; } break; - case 225 /* EnumDeclaration */: - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); - return true; - case 178 /* TypeAssertionExpression */: - var typeAssertionExpression = node; - diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); - return true; - case 144 /* Decorator */: - if (!options.experimentalDecorators) { - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning)); + case 144 /* Parameter */: + // Check modifiers of parameter declaration + if (nodes === parent.modifiers) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); + return; } - return true; - } - return ts.forEachChild(node, walk); - } - function checkTypeParameters(typeParameters) { - if (typeParameters) { - var start = typeParameters.pos; - diagnostics.push(ts.createFileDiagnostic(sourceFile, start, typeParameters.end - start, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkTypeAnnotation(type) { - if (type) { - diagnostics.push(ts.createDiagnosticForNode(type, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); - return true; - } - return false; - } - function checkModifiers(modifiers) { - if (modifiers) { - for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { - var modifier = modifiers_1[_i]; - switch (modifier.kind) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 129 /* ReadonlyKeyword */: - case 123 /* DeclareKeyword */: - diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); - return true; - // These are all legal modifiers. - case 114 /* StaticKeyword */: - case 83 /* ExportKeyword */: - case 75 /* ConstKeyword */: - case 78 /* DefaultKeyword */: - case 116 /* AbstractKeyword */: + break; + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 198 /* ExpressionWithTypeArguments */: + // Check type arguments + if (nodes === parent.typeArguments) { + diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); + return; } + break; + } + for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { + var node = nodes_4[_b]; + walk(node); + } + } + function checkModifiers(modifiers, isConstValid) { + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; + switch (modifier.kind) { + case 75 /* ConstKeyword */: + if (isConstValid) { + continue; + } + // Fallthrough to report error + case 113 /* PublicKeyword */: + case 111 /* PrivateKeyword */: + case 112 /* ProtectedKeyword */: + case 130 /* ReadonlyKeyword */: + case 123 /* DeclareKeyword */: + case 116 /* AbstractKeyword */: + diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); + break; + // These are all legal modifiers. + case 114 /* StaticKeyword */: + case 83 /* ExportKeyword */: + case 78 /* DefaultKeyword */: } } - return false; + } + function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) { + var start = nodes.pos; + return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2); + } + // Since these are syntactic diagnostics, parent might not have been set + // this means the sourceFile cannot be infered from the node + function createDiagnosticForNode(node, message, arg0, arg1, arg2) { + return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } }); } @@ -59713,9 +61687,6 @@ var ts; ts.addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics()); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function hasExtension(fileName) { - return ts.getBaseFileName(fileName).indexOf(".") >= 0; - } function processRootFile(fileName, isDefaultLib) { processSourceFile(ts.normalizePath(fileName), isDefaultLib); } @@ -59734,16 +61705,21 @@ var ts; } var isJavaScriptFile = ts.isSourceFileJavaScript(file); var isExternalModuleFile = ts.isExternalModule(file); + var isDtsFile = ts.isDeclarationFile(file); var imports; var moduleAugmentations; + 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) && !file.isDeclarationFile) { - var externalHelpersModuleReference = ts.createNode(9 /* StringLiteral */); + // synthesize 'import "tslib"' declaration + var externalHelpersModuleReference = ts.createSynthesizedNode(9 /* StringLiteral */); externalHelpersModuleReference.text = ts.externalHelpersModuleNameText; - externalHelpersModuleReference.parent = file; + var importDecl = ts.createSynthesizedNode(234 /* ImportDeclaration */); + importDecl.parent = file; + externalHelpersModuleReference.parent = importDecl; imports = [externalHelpersModuleReference]; } for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { @@ -59755,12 +61731,13 @@ var ts; } file.imports = imports || emptyArray; file.moduleAugmentations = moduleAugmentations || emptyArray; + file.ambientModuleNames = ambientModules || emptyArray; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 231 /* ImportDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 237 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 240 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -59775,7 +61752,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -59787,6 +61764,10 @@ var ts; (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { + if (isDtsFile) { + // for global .d.ts files record name of ambient module + (ambientModules || (ambientModules = [])).push(moduleName.text); + } // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. @@ -59812,13 +61793,10 @@ var ts; } } } - /** - * 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration) - */ function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var diagnosticArgument; var diagnostic; - if (hasExtension(fileName)) { + if (ts.hasExtension(fileName)) { if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensions, function (extension) { return ts.fileExtensionIs(host.getCanonicalFileName(fileName), extension); })) { diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"]; @@ -59884,7 +61862,7 @@ var ts; processImportedModules(file_1); } else if (file_1 && modulesWithElidedImports[file_1.path]) { - if (currentNodeModulesDepth < maxNodeModulesJsDepth) { + if (currentNodeModulesDepth < maxNodeModuleJsDepth) { modulesWithElidedImports[file_1.path] = false; processImportedModules(file_1); } @@ -60004,29 +61982,39 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { file.resolvedModules = ts.createMap(); - var moduleNames = ts.map(ts.concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); - var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory)); + // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. + var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9 /* StringLiteral */; }); + var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + ts.Debug.assert(resolutions.length === moduleNames.length); for (var i = 0; i < moduleNames.length; i++) { var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); + if (!resolution) { + continue; + } + var isFromNodeModulesSearch = resolution.isExternalLibraryImport; + var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var resolvedFileName = resolution.resolvedFileName; + if (isFromNodeModulesSearch) { + currentNodeModulesDepth++; + } // add file to program only if: // - resolution was successful // - noResolve is falsy // - module name comes from the list of imports // - it's not a top level JavaScript module that exceeded the search max - var isFromNodeModulesSearch = resolution && resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && ts.hasJavaScriptFileExtension(resolution.resolvedFileName); - if (isFromNodeModulesSearch) { - currentNodeModulesDepth++; - } - var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModulesJsDepth; - var shouldAddFile = resolution && !options.noResolve && i < file.imports.length && !elideImport; + var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; + // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') + // This may still end up being an untyped module -- the file won't be included but imports will be allowed. + var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; if (elideImport) { modulesWithElidedImports[file.path] = true; } else if (shouldAddFile) { - findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), - /*isDefaultLib*/ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var path = ts.toPath(resolvedFileName, currentDirectory, getCanonicalFileName); + var pos = ts.skipTrivia(file.text, file.imports[i].pos); + findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, file, pos, file.imports[i].end); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -60037,7 +62025,6 @@ var ts; // no imports - drop cached module resolutions file.resolvedModules = undefined; } - return; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; @@ -60198,7 +62185,15 @@ var ts; !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); } - if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { + if (options.jsxFactory) { + if (options.reactNamespace) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory")); + } + if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory)); + } + } + else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace)); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files @@ -60216,18 +62211,13 @@ var ts; var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName); // Report error if the output overwrites input file if (filesByName.contains(emitFilePath)) { - if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) { - blockEmittingOfFile(emitFileName); - } - else { - var chain_1; - if (!options.configFilePath) { - // The program is from either an inferred project or an external project - chain_1 = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); - } - chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); - blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); + var chain_1; + if (!options.configFilePath) { + // The program is from either an inferred project or an external project + chain_1 = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig); } + chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName); + blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1)); } // Report error if multiple files write into same file if (emitFilesSeen.contains(emitFilePath)) { @@ -60242,12 +62232,38 @@ var ts; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true); - if (diag) { - programDiagnostics.add(diag); - } + programDiagnostics.add(diag); } } ts.createProgram = createProgram; + /* @internal */ + /** + * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. + * The DiagnosticMessage's parameters are the imported module name, and the filename it resolved to. + * This returns a diagnostic even if the module will be an untyped module. + */ + function getResolutionDiagnostic(options, _a) { + var extension = _a.extension; + switch (extension) { + case ts.Extension.Ts: + case ts.Extension.Dts: + // These are always allowed. + return undefined; + case ts.Extension.Tsx: + return needJsx(); + case ts.Extension.Jsx: + return needJsx() || needAllowJs(); + case ts.Extension.Js: + return needAllowJs(); + } + function needJsx() { + return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; + } + function needAllowJs() { + return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + } + } + ts.getResolutionDiagnostic = getResolutionDiagnostic; })(ts || (ts = {})); /// /// @@ -60328,6 +62344,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -60516,6 +62537,7 @@ var ts; "es2015": 2 /* ES2015 */, "es2016": 3 /* ES2016 */, "es2017": 4 /* ES2017 */, + "esnext": 5 /* ESNext */, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -60679,7 +62701,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -60976,11 +62999,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_44 in options) { - if (ts.hasProperty(options, name_44)) { + for (var name_41 in options) { + if (ts.hasProperty(options, name_41)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_44) { + switch (name_41) { case "init": case "watch": case "version": @@ -60988,14 +63011,14 @@ var ts; case "project": break; default: - var value = options[name_44]; - var optionDefinition = optionsNameMap[name_44.toLowerCase()]; + var value = options[name_41]; + var optionDefinition = optionsNameMap[name_41.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_44] = value; + result[name_41] = value; } else { if (optionDefinition.type === "list") { @@ -61004,11 +63027,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_44] = convertedValue; + result[name_41] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_44] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_41] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -61218,9 +63241,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -61452,6 +63473,7 @@ var ts; // // /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively // /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added + // /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler // // We watch a directory without recursion if it contains a wildcard in the file segment of // the pattern: @@ -61465,14 +63487,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_45 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_45)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_45); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_45) ? 1 /* Recursive */ : 0 /* None */; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -61494,6 +63515,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 /* Recursive */ : 0 /* None */ + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 /* Recursive */ }; + } + return undefined; + } /** * Determines whether a literal or wildcard file has already been included that has a higher * extension priority. @@ -61597,12 +63631,13 @@ var ts; HighlightSpanKind.reference = "reference"; HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); + var IndentStyle; (function (IndentStyle) { IndentStyle[IndentStyle["None"] = 0] = "None"; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; - })(ts.IndentStyle || (ts.IndentStyle = {})); - var IndentStyle = ts.IndentStyle; + })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SymbolDisplayPartKind; (function (SymbolDisplayPartKind) { SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; @@ -61626,14 +63661,14 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; - })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); - var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; + })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var OutputFileType; (function (OutputFileType) { OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(ts.OutputFileType || (ts.OutputFileType = {})); - var OutputFileType = ts.OutputFileType; + })(OutputFileType = ts.OutputFileType || (ts.OutputFileType = {})); + var EndOfLineState; (function (EndOfLineState) { EndOfLineState[EndOfLineState["None"] = 0] = "None"; EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; @@ -61642,8 +63677,8 @@ var ts; EndOfLineState[EndOfLineState["InTemplateHeadOrNoSubstitutionTemplate"] = 4] = "InTemplateHeadOrNoSubstitutionTemplate"; EndOfLineState[EndOfLineState["InTemplateMiddleOrTail"] = 5] = "InTemplateMiddleOrTail"; EndOfLineState[EndOfLineState["InTemplateSubstitutionPosition"] = 6] = "InTemplateSubstitutionPosition"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; + })(EndOfLineState = ts.EndOfLineState || (ts.EndOfLineState = {})); + var TokenClass; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -61654,8 +63689,7 @@ var ts; TokenClass[TokenClass["NumberLiteral"] = 6] = "NumberLiteral"; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; - })(ts.TokenClass || (ts.TokenClass = {})); - var TokenClass = ts.TokenClass; + })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); // TODO: move these to enums var ScriptElementKind; (function (ScriptElementKind) { @@ -61762,6 +63796,7 @@ var ts; ClassificationTypeNames.jsxText = "jsx text"; ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; ts.ClassificationTypeNames = ClassificationTypeNames; + var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; ClassificationType[ClassificationType["identifier"] = 2] = "identifier"; @@ -61787,52 +63822,51 @@ var ts; ClassificationType[ClassificationType["jsxAttribute"] = 22] = "jsxAttribute"; ClassificationType[ClassificationType["jsxText"] = 23] = "jsxText"; ClassificationType[ClassificationType["jsxAttributeStringLiteralValue"] = 24] = "jsxAttributeStringLiteralValue"; - })(ts.ClassificationType || (ts.ClassificationType = {})); - var ClassificationType = ts.ClassificationType; + })(ClassificationType = ts.ClassificationType || (ts.ClassificationType = {})); })(ts || (ts = {})); // These utilities are common to multiple language service features. /* @internal */ var ts; (function (ts) { - ts.scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); ts.emptyArray = []; + var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; SemanticMeaning[SemanticMeaning["Value"] = 1] = "Value"; SemanticMeaning[SemanticMeaning["Type"] = 2] = "Type"; SemanticMeaning[SemanticMeaning["Namespace"] = 4] = "Namespace"; SemanticMeaning[SemanticMeaning["All"] = 7] = "All"; - })(ts.SemanticMeaning || (ts.SemanticMeaning = {})); - var SemanticMeaning = ts.SemanticMeaning; + })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 143 /* Parameter */: - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: - case 255 /* EnumMember */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 252 /* CatchClause */: + case 144 /* Parameter */: + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: + case 259 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 255 /* CatchClause */: return 1 /* Value */; - case 142 /* TypeParameter */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 160 /* TypeLiteral */: + case 143 /* TypeParameter */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 161 /* TypeLiteral */: return 2 /* Type */; - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -61842,22 +63876,22 @@ var ts; else { return 4 /* Namespace */; } - case 234 /* NamedImports */: - case 235 /* ImportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 231 /* ImportDeclaration */: - case 236 /* ExportAssignment */: - case 237 /* ExportDeclaration */: + case 237 /* NamedImports */: + case 238 /* ImportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 234 /* ImportDeclaration */: + case 239 /* ExportAssignment */: + case 240 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 256 /* SourceFile */: + case 260 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.parent.kind === 236 /* ExportAssignment */) { + if (node.parent.kind === 239 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -61882,15 +63916,15 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 140 /* QualifiedName */ && + if (node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 230 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 233 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 140 /* QualifiedName */) { + while (node.parent.kind === 141 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -61901,27 +63935,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 140 /* QualifiedName */) { - while (root.parent && root.parent.kind === 140 /* QualifiedName */) { + if (root.parent.kind === 141 /* QualifiedName */) { + while (root.parent && root.parent.kind === 141 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 156 /* TypeReference */ && !isLastClause; + return root.parent.kind === 157 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 173 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 173 /* PropertyAccessExpression */) { + if (root.parent.kind === 176 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 176 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 195 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 251 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 198 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 254 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 222 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 223 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 225 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || + (decl.kind === 226 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); } return false; } @@ -61929,17 +63963,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 156 /* TypeReference */ || - (node.parent.kind === 195 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + return node.parent.kind === 157 /* TypeReference */ || + (node.parent.kind === 198 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 166 /* ThisType */; + node.kind === 167 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 175 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 178 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 176 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 179 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -61952,7 +63986,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 215 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 218 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -61962,13 +63996,13 @@ var ts; ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { return node.kind === 70 /* Identifier */ && - (node.parent.kind === 211 /* BreakStatement */ || node.parent.kind === 210 /* ContinueStatement */) && + (node.parent.kind === 214 /* BreakStatement */ || node.parent.kind === 213 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { return node.kind === 70 /* Identifier */ && - node.parent.kind === 215 /* LabeledStatement */ && + node.parent.kind === 218 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -61976,15 +64010,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 140 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 141 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 173 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 176 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 226 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 229 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -61995,19 +64029,19 @@ var ts; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 253 /* PropertyAssignment */: - case 255 /* EnumMember */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 226 /* ModuleDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 256 /* PropertyAssignment */: + case 259 /* EnumMember */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 229 /* ModuleDeclaration */: return node.parent.name === node; - case 174 /* ElementAccessExpression */: + case 177 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 141 /* ComputedPropertyName */: + case 142 /* ComputedPropertyName */: return true; } } @@ -62056,17 +64090,17 @@ var ts; return undefined; } switch (node.kind) { - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: return node; } } @@ -62074,46 +64108,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 223 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 224 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 225 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 219 /* VariableDeclaration */: + case 226 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 227 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 228 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 222 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 170 /* BindingElement */: + case 173 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 150 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 151 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 151 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 152 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 154 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 153 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 152 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 149 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 142 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 255 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 143 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 230 /* ImportEqualsDeclaration */: - case 235 /* ImportSpecifier */: - case 232 /* ImportClause */: - case 239 /* ExportSpecifier */: - case 233 /* NamespaceImport */: + case 155 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 154 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 153 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 150 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 143 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 259 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 144 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 233 /* ImportEqualsDeclaration */: + case 238 /* ImportSpecifier */: + case 235 /* ImportClause */: + case 242 /* ExportSpecifier */: + case 236 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -62128,7 +64162,7 @@ var ts; } ts.getNodeKind = getNodeKind; function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 167 /* LiteralType */ ? node.parent : node; + var searchNode = node.parent.kind === 170 /* LiteralType */ ? node.parent : node; var type = typeChecker.getTypeAtLocation(searchNode); if (type && type.flags & 32 /* StringLiteral */) { return type; @@ -62143,7 +64177,7 @@ var ts; return true; case 70 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 143 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 144 /* Parameter */; default: return false; } @@ -62188,42 +64222,42 @@ var ts; return false; } switch (n.kind) { - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 168 /* ObjectBindingPattern */: - case 160 /* TypeLiteral */: - case 200 /* Block */: - case 227 /* ModuleBlock */: - case 228 /* CaseBlock */: - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 171 /* ObjectBindingPattern */: + case 161 /* TypeLiteral */: + case 203 /* Block */: + case 230 /* ModuleBlock */: + case 231 /* CaseBlock */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return nodeEndsWith(n, 17 /* CloseBraceToken */, sourceFile); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 176 /* NewExpression */: + case 179 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 175 /* CallExpression */: - case 179 /* ParenthesizedExpression */: - case 165 /* ParenthesizedType */: + case 178 /* CallExpression */: + case 182 /* ParenthesizedExpression */: + case 166 /* ParenthesizedType */: return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); - case 157 /* FunctionType */: - case 158 /* ConstructorType */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 153 /* ConstructSignature */: - case 152 /* CallSignature */: - case 181 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 154 /* ConstructSignature */: + case 153 /* CallSignature */: + case 184 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -62233,67 +64267,67 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 19 /* CloseParenToken */, sourceFile); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 204 /* IfStatement */: + case 207 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 24 /* SemicolonToken */); - case 171 /* ArrayLiteralExpression */: - case 169 /* ArrayBindingPattern */: - case 174 /* ElementAccessExpression */: - case 141 /* ComputedPropertyName */: - case 162 /* TupleType */: + case 174 /* ArrayLiteralExpression */: + case 172 /* ArrayBindingPattern */: + case 177 /* ElementAccessExpression */: + case 142 /* ComputedPropertyName */: + case 163 /* TupleType */: return nodeEndsWith(n, 21 /* CloseBracketToken */, sourceFile); - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 205 /* DoStatement */: + case 208 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; var hasWhileKeyword = findChildOfKind(n, 105 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 19 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 159 /* TypeQuery */: + case 160 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 183 /* TypeOfExpression */: - case 182 /* DeleteExpression */: - case 184 /* VoidExpression */: - case 191 /* YieldExpression */: - case 192 /* SpreadElementExpression */: + case 186 /* TypeOfExpression */: + case 185 /* DeleteExpression */: + case 187 /* VoidExpression */: + case 194 /* YieldExpression */: + case 195 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 177 /* TaggedTemplateExpression */: + case 180 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 190 /* TemplateExpression */: + case 193 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 198 /* TemplateSpan */: + case 201 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 237 /* ExportDeclaration */: - case 231 /* ImportDeclaration */: + case 240 /* ExportDeclaration */: + case 234 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 186 /* PrefixUnaryExpression */: + case 189 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 189 /* ConditionalExpression */: + case 192 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -62349,7 +64383,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 286 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 290 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -62521,7 +64555,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 256 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 260 /* SourceFile */); // 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. @@ -62580,17 +64614,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 248 /* JsxExpression */) { + if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 251 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 245 /* JsxClosingElement */) { + if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 248 /* JsxClosingElement */) { return true; } return false; @@ -62702,17 +64736,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 156 /* TypeReference */ || node.kind === 175 /* CallExpression */) { + if (node.kind === 157 /* TypeReference */ || node.kind === 178 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 222 /* ClassDeclaration */ || node.kind === 223 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 225 /* ClassDeclaration */ || node.kind === 226 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 139 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 140 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { @@ -62771,18 +64805,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 171 /* ArrayLiteralExpression */ || - node.kind === 172 /* ObjectLiteralExpression */) { + if (node.kind === 174 /* ArrayLiteralExpression */ || + node.kind === 175 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 188 /* BinaryExpression */ && + if (node.parent.kind === 191 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 209 /* ForOfStatement */ && + if (node.parent.kind === 212 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -62790,7 +64824,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 253 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 256 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -62823,7 +64857,7 @@ var ts; /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 143 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 144 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -63003,7 +65037,7 @@ var ts; return location.getText(); } else if (ts.isStringOrNumericLiteral(location.kind) && - location.parent.kind === 141 /* ComputedPropertyName */) { + location.parent.kind === 142 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' @@ -63015,7 +65049,7 @@ var ts; ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 235 /* ImportSpecifier */ || location.parent.kind === 239 /* ExportSpecifier */) && + (location.parent.kind === 238 /* ImportSpecifier */ || location.parent.kind === 242 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -63087,7 +65121,7 @@ var ts; (function (ts) { /// Classifier function createClassifier() { - var scanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false); /// We do not have a full parser support to know when we should parse a regex or not /// If we consider every slash token to be a regex, we could be missing cases like "1/2/3", where /// we have a series of divide operator. this list allows us to be more accurate by ruling out @@ -63130,7 +65164,7 @@ var ts; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 132 /* SetKeyword */ || + keyword2 === 133 /* SetKeyword */ || keyword2 === 122 /* ConstructorKeyword */ || keyword2 === 114 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". @@ -63289,10 +65323,10 @@ var ts; angleBracketStack--; } else if (token === 118 /* AnyKeyword */ || - token === 133 /* StringKeyword */ || - token === 131 /* NumberKeyword */ || + token === 134 /* StringKeyword */ || + token === 132 /* NumberKeyword */ || token === 121 /* BooleanKeyword */ || - token === 134 /* SymbolKeyword */) { + token === 135 /* 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, @@ -63464,7 +65498,7 @@ var ts; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 139 /* LastKeyword */; + return token >= 71 /* FirstKeyword */ && token <= 140 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -63521,10 +65555,10 @@ 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 226 /* ModuleDeclaration */: - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: + case 229 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -63575,7 +65609,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 226 /* ModuleDeclaration */ && + return declaration.kind === 229 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -63654,8 +65688,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -63739,16 +65773,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 275 /* JSDocParameterTag */: + case 279 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 278 /* JSDocTemplateTag */: + case 282 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 277 /* JSDocTypeTag */: + case 281 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 276 /* JSDocReturnTag */: + case 280 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -63835,22 +65869,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 244 /* JsxOpeningElement */: + case 247 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 245 /* JsxClosingElement */: + case 248 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 243 /* JsxSelfClosingElement */: + case 246 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 246 /* JsxAttribute */: + case 249 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -63878,17 +65912,17 @@ var ts; if (token) { if (tokenKind === 57 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 219 /* VariableDeclaration */ || - token.parent.kind === 146 /* PropertyDeclaration */ || - token.parent.kind === 143 /* Parameter */ || - token.parent.kind === 246 /* JsxAttribute */) { + if (token.parent.kind === 222 /* VariableDeclaration */ || + token.parent.kind === 147 /* PropertyDeclaration */ || + token.parent.kind === 144 /* Parameter */ || + token.parent.kind === 249 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 188 /* BinaryExpression */ || - token.parent.kind === 186 /* PrefixUnaryExpression */ || - token.parent.kind === 187 /* PostfixUnaryExpression */ || - token.parent.kind === 189 /* ConditionalExpression */) { + if (token.parent.kind === 191 /* BinaryExpression */ || + token.parent.kind === 189 /* PrefixUnaryExpression */ || + token.parent.kind === 190 /* PostfixUnaryExpression */ || + token.parent.kind === 192 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -63898,7 +65932,7 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 246 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 249 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 11 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -63914,32 +65948,32 @@ var ts; else if (tokenKind === 70 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 142 /* TypeParameter */: + case 143 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 143 /* Parameter */: + case 144 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -63999,7 +66033,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 245 /* JsxClosingElement */) { + location.parent && location.parent.kind === 248 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. // For example: @@ -64026,14 +66060,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_46 in nameTable) { + for (var name_42 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_46] === position) { + if (nameTable[name_42] === position) { continue; } - if (!uniqueNames[name_46]) { - uniqueNames[name_46] = name_46; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_46), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_42]) { + uniqueNames[name_42] = name_42; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_42), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -64093,8 +66127,8 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 253 /* PropertyAssignment */ && - node.parent.parent.kind === 172 /* ObjectLiteralExpression */ && + if (node.parent.kind === 256 /* PropertyAssignment */ && + node.parent.parent.kind === 175 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -64119,7 +66153,7 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === 231 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 234 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); @@ -64510,8 +66544,8 @@ var ts; } catch (e) { } if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; + for (var _b = 0, typeRoots_3 = typeRoots; _b < typeRoots_3.length; _b++) { + var root = typeRoots_3[_b]; getCompletionEntriesFromDirectories(host, root, span, result); } } @@ -64546,11 +66580,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_16 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_16) { + var parent_15 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_15) { break; } - currentDir = parent_16; + currentDir = parent_15; } else { break; @@ -64702,9 +66736,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 277 /* JSDocTypeTag */: - case 275 /* JSDocParameterTag */: - case 276 /* JSDocReturnTag */: + case 281 /* JSDocTypeTag */: + case 279 /* JSDocParameterTag */: + case 280 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -64749,13 +66783,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_17 = contextToken.parent, kind = contextToken.kind; + var parent_16 = contextToken.parent, kind = contextToken.kind; if (kind === 22 /* DotToken */) { - if (parent_17.kind === 173 /* PropertyAccessExpression */) { + if (parent_16.kind === 176 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_17.kind === 140 /* QualifiedName */) { + else if (parent_16.kind === 141 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -64770,7 +66804,7 @@ var ts; isRightOfOpenTag = true; location = contextToken; } - else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 245 /* JsxClosingElement */) { + else if (kind === 40 /* SlashToken */ && contextToken.parent.kind === 248 /* JsxClosingElement */) { isStartingCloseTag = true; location = contextToken; } @@ -64819,7 +66853,7 @@ var ts; isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 140 /* QualifiedName */ || node.kind === 173 /* PropertyAccessExpression */) { + if (node.kind === 70 /* Identifier */ || node.kind === 141 /* QualifiedName */ || node.kind === 176 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -64875,7 +66909,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 243 /* JsxSelfClosingElement */) || (jsxContainer.kind === 244 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 246 /* JsxSelfClosingElement */) || (jsxContainer.kind === 247 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); if (attrsType) { @@ -64923,9 +66957,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 256 /* SourceFile */ || - scopeNode.kind === 190 /* TemplateExpression */ || - scopeNode.kind === 248 /* JsxExpression */ || + scopeNode.kind === 260 /* SourceFile */ || + scopeNode.kind === 193 /* TemplateExpression */ || + scopeNode.kind === 251 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -64958,11 +66992,11 @@ var ts; return true; } if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 244 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 247 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 245 /* JsxClosingElement */ || contextToken.parent.kind === 243 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 242 /* JsxElement */; + if (contextToken.parent.kind === 248 /* JsxClosingElement */ || contextToken.parent.kind === 246 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 245 /* JsxElement */; } } return false; @@ -64972,40 +67006,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 175 /* CallExpression */ // func( a, | - || containingNodeKind === 149 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 176 /* NewExpression */ // new C(a, | - || containingNodeKind === 171 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 188 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 157 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 178 /* CallExpression */ // func( a, | + || containingNodeKind === 150 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 179 /* NewExpression */ // new C(a, | + || containingNodeKind === 174 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 191 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 158 /* FunctionType */; // var x: (s: string, list| case 18 /* OpenParenToken */: - return containingNodeKind === 175 /* CallExpression */ // func( | - || containingNodeKind === 149 /* Constructor */ // constructor( | - || containingNodeKind === 176 /* NewExpression */ // new C(a| - || containingNodeKind === 179 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 165 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 178 /* CallExpression */ // func( | + || containingNodeKind === 150 /* Constructor */ // constructor( | + || containingNodeKind === 179 /* NewExpression */ // new C(a| + || containingNodeKind === 182 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 166 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 20 /* OpenBracketToken */: - return containingNodeKind === 171 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 154 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 141 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 126 /* ModuleKeyword */: // module | - case 127 /* NamespaceKeyword */: + return containingNodeKind === 174 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 155 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 142 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 127 /* ModuleKeyword */: // module | + case 128 /* NamespaceKeyword */: return true; case 22 /* DotToken */: - return containingNodeKind === 226 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 229 /* ModuleDeclaration */; // module A.| case 16 /* OpenBraceToken */: - return containingNodeKind === 222 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 225 /* ClassDeclaration */; // class A{ | case 57 /* EqualsToken */: - return containingNodeKind === 219 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 188 /* BinaryExpression */; // x = a| + return containingNodeKind === 222 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 191 /* BinaryExpression */; // x = a| case 13 /* TemplateHead */: - return containingNodeKind === 190 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 193 /* TemplateExpression */; // `aa ${| case 14 /* TemplateMiddle */: - return containingNodeKind === 198 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 201 /* TemplateSpan */; // `aa ${10} dd ${| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 146 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 147 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -65048,7 +67082,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 172 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 175 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -65058,7 +67092,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 168 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 171 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -65069,11 +67103,11 @@ var ts; // 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 = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 143 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 144 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 148 /* MethodDeclaration */ || rootDeclaration.parent.kind === 151 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 149 /* MethodDeclaration */ || rootDeclaration.parent.kind === 152 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -65115,9 +67149,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 234 /* NamedImports */ ? - 231 /* ImportDeclaration */ : - 237 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 237 /* NamedImports */ ? + 234 /* ImportDeclaration */ : + 240 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -65142,9 +67176,9 @@ var ts; switch (contextToken.kind) { case 16 /* OpenBraceToken */: // const x = { | case 25 /* CommaToken */: - var parent_18 = contextToken.parent; - if (parent_18 && (parent_18.kind === 172 /* ObjectLiteralExpression */ || parent_18.kind === 168 /* ObjectBindingPattern */)) { - return parent_18; + var parent_17 = contextToken.parent; + if (parent_17 && (parent_17.kind === 175 /* ObjectLiteralExpression */ || parent_17.kind === 171 /* ObjectBindingPattern */)) { + return parent_17; } break; } @@ -65161,8 +67195,8 @@ var ts; case 16 /* OpenBraceToken */: // import { | case 25 /* CommaToken */: switch (contextToken.parent.kind) { - case 234 /* NamedImports */: - case 238 /* NamedExports */: + case 237 /* NamedImports */: + case 241 /* NamedExports */: return contextToken.parent; } } @@ -65171,37 +67205,37 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_19 = contextToken.parent; + var parent_18 = contextToken.parent; switch (contextToken.kind) { case 27 /* LessThanSlashToken */: case 40 /* SlashToken */: case 70 /* Identifier */: - case 246 /* JsxAttribute */: - case 247 /* JsxSpreadAttribute */: - if (parent_19 && (parent_19.kind === 243 /* JsxSelfClosingElement */ || parent_19.kind === 244 /* JsxOpeningElement */)) { - return parent_19; + case 249 /* JsxAttribute */: + case 250 /* JsxSpreadAttribute */: + if (parent_18 && (parent_18.kind === 246 /* JsxSelfClosingElement */ || parent_18.kind === 247 /* JsxOpeningElement */)) { + return parent_18; } - else if (parent_19.kind === 246 /* JsxAttribute */) { - return parent_19.parent; + else if (parent_18.kind === 249 /* JsxAttribute */) { + return parent_18.parent; } break; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent_19 && ((parent_19.kind === 246 /* JsxAttribute */) || (parent_19.kind === 247 /* JsxSpreadAttribute */))) { - return parent_19.parent; + if (parent_18 && ((parent_18.kind === 249 /* JsxAttribute */) || (parent_18.kind === 250 /* JsxSpreadAttribute */))) { + return parent_18.parent; } break; case 17 /* CloseBraceToken */: - if (parent_19 && - parent_19.kind === 248 /* JsxExpression */ && - parent_19.parent && - (parent_19.parent.kind === 246 /* JsxAttribute */)) { - return parent_19.parent.parent; + if (parent_18 && + parent_18.kind === 251 /* JsxExpression */ && + parent_18.parent && + (parent_18.parent.kind === 249 /* JsxAttribute */)) { + return parent_18.parent.parent; } - if (parent_19 && parent_19.kind === 247 /* JsxSpreadAttribute */) { - return parent_19.parent; + if (parent_18 && parent_18.kind === 250 /* JsxSpreadAttribute */) { + return parent_18.parent; } break; } @@ -65210,16 +67244,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 154 /* IndexSignature */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 155 /* IndexSignature */: return true; } return false; @@ -65231,66 +67265,66 @@ var ts; var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { case 25 /* CommaToken */: - return containingNodeKind === 219 /* VariableDeclaration */ || - containingNodeKind === 220 /* VariableDeclarationList */ || - containingNodeKind === 201 /* VariableStatement */ || - containingNodeKind === 225 /* EnumDeclaration */ || + return containingNodeKind === 222 /* VariableDeclaration */ || + containingNodeKind === 223 /* VariableDeclarationList */ || + containingNodeKind === 204 /* VariableStatement */ || + containingNodeKind === 228 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 169 /* ArrayBindingPattern */ || - containingNodeKind === 224 /* TypeAliasDeclaration */; // type Map, K, | + containingNodeKind === 225 /* ClassDeclaration */ || + containingNodeKind === 196 /* ClassExpression */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 172 /* ArrayBindingPattern */ || + containingNodeKind === 227 /* TypeAliasDeclaration */; // type Map, K, | case 22 /* DotToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 172 /* ArrayBindingPattern */; // var [.| case 55 /* ColonToken */: - return containingNodeKind === 170 /* BindingElement */; // var {x :html| + return containingNodeKind === 173 /* BindingElement */; // var {x :html| case 20 /* OpenBracketToken */: - return containingNodeKind === 169 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 172 /* ArrayBindingPattern */; // var [x| case 18 /* OpenParenToken */: - return containingNodeKind === 252 /* CatchClause */ || + return containingNodeKind === 255 /* CatchClause */ || isFunction(containingNodeKind); case 16 /* OpenBraceToken */: - return containingNodeKind === 225 /* EnumDeclaration */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 160 /* TypeLiteral */; // const x : { | + return containingNodeKind === 228 /* EnumDeclaration */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 161 /* TypeLiteral */; // const x : { | case 24 /* SemicolonToken */: - return containingNodeKind === 145 /* PropertySignature */ && + return containingNodeKind === 146 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 223 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 160 /* TypeLiteral */); // const x : { a; | + (contextToken.parent.parent.kind === 226 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 161 /* TypeLiteral */); // const x : { a; | case 26 /* LessThanToken */: - return containingNodeKind === 222 /* ClassDeclaration */ || - containingNodeKind === 193 /* ClassExpression */ || - containingNodeKind === 223 /* InterfaceDeclaration */ || - containingNodeKind === 224 /* TypeAliasDeclaration */ || + return containingNodeKind === 225 /* ClassDeclaration */ || + containingNodeKind === 196 /* ClassExpression */ || + containingNodeKind === 226 /* InterfaceDeclaration */ || + containingNodeKind === 227 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); case 114 /* StaticKeyword */: - return containingNodeKind === 146 /* PropertyDeclaration */; + return containingNodeKind === 147 /* PropertyDeclaration */; case 23 /* DotDotDotToken */: - return containingNodeKind === 143 /* Parameter */ || + return containingNodeKind === 144 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 169 /* ArrayBindingPattern */); // var [...z| + contextToken.parent.parent.kind === 172 /* ArrayBindingPattern */); // var [...z| case 113 /* PublicKeyword */: case 111 /* PrivateKeyword */: case 112 /* ProtectedKeyword */: - return containingNodeKind === 143 /* Parameter */; + return containingNodeKind === 144 /* Parameter */; case 117 /* AsKeyword */: - return containingNodeKind === 235 /* ImportSpecifier */ || - containingNodeKind === 239 /* ExportSpecifier */ || - containingNodeKind === 233 /* NamespaceImport */; + return containingNodeKind === 238 /* ImportSpecifier */ || + containingNodeKind === 242 /* ExportSpecifier */ || + containingNodeKind === 236 /* NamespaceImport */; case 74 /* ClassKeyword */: case 82 /* EnumKeyword */: case 108 /* InterfaceKeyword */: case 88 /* FunctionKeyword */: case 103 /* VarKeyword */: case 124 /* GetKeyword */: - case 132 /* SetKeyword */: + case 133 /* SetKeyword */: case 90 /* ImportKeyword */: case 109 /* LetKeyword */: case 75 /* ConstKeyword */: case 115 /* YieldKeyword */: - case 135 /* TypeKeyword */: + case 136 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -65338,8 +67372,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_47 = element.propertyName || element.name; - existingImportsOrExports[name_47.text] = true; + var name_43 = element.propertyName || element.name; + existingImportsOrExports[name_43.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -65360,10 +67394,12 @@ 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 !== 253 /* PropertyAssignment */ && - m.kind !== 254 /* ShorthandPropertyAssignment */ && - m.kind !== 170 /* BindingElement */ && - m.kind !== 148 /* MethodDeclaration */) { + if (m.kind !== 256 /* PropertyAssignment */ && + m.kind !== 257 /* ShorthandPropertyAssignment */ && + m.kind !== 173 /* BindingElement */ && + m.kind !== 149 /* MethodDeclaration */ && + m.kind !== 151 /* GetAccessor */ && + m.kind !== 152 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -65371,7 +67407,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 170 /* BindingElement */ && m.propertyName) { + if (m.kind === 173 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 70 /* Identifier */) { existingName = m.propertyName.text; @@ -65401,7 +67437,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 246 /* JsxAttribute */) { + if (attr.kind === 249 /* JsxAttribute */) { seenNames[attr.name.text] = true; } } @@ -65451,7 +67487,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 139 /* LastKeyword */; i++) { + for (var i = 71 /* FirstKeyword */; i <= 140 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -65528,7 +67564,7 @@ var ts; function getSemanticDocumentHighlights(node) { if (node.kind === 70 /* Identifier */ || node.kind === 98 /* ThisKeyword */ || - node.kind === 166 /* ThisType */ || + node.kind === 167 /* ThisType */ || node.kind === 96 /* SuperKeyword */ || node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { @@ -65582,75 +67618,75 @@ var ts; switch (node.kind) { case 89 /* IfKeyword */: case 81 /* ElseKeyword */: - if (hasKind(node.parent, 204 /* IfStatement */)) { + if (hasKind(node.parent, 207 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; case 95 /* ReturnKeyword */: - if (hasKind(node.parent, 212 /* ReturnStatement */)) { + if (hasKind(node.parent, 215 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; case 99 /* ThrowKeyword */: - if (hasKind(node.parent, 216 /* ThrowStatement */)) { + if (hasKind(node.parent, 219 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; case 73 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 217 /* TryStatement */)) { + if (hasKind(parent(parent(node)), 220 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; case 101 /* TryKeyword */: case 86 /* FinallyKeyword */: - if (hasKind(parent(node), 217 /* TryStatement */)) { + if (hasKind(parent(node), 220 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; case 97 /* SwitchKeyword */: - if (hasKind(node.parent, 214 /* SwitchStatement */)) { + if (hasKind(node.parent, 217 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; case 72 /* CaseKeyword */: case 78 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 214 /* SwitchStatement */)) { + if (hasKind(parent(parent(parent(node))), 217 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; case 71 /* BreakKeyword */: case 76 /* ContinueKeyword */: - if (hasKind(node.parent, 211 /* BreakStatement */) || hasKind(node.parent, 210 /* ContinueStatement */)) { + if (hasKind(node.parent, 214 /* BreakStatement */) || hasKind(node.parent, 213 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurrences(node.parent); } break; case 87 /* ForKeyword */: - if (hasKind(node.parent, 207 /* ForStatement */) || - hasKind(node.parent, 208 /* ForInStatement */) || - hasKind(node.parent, 209 /* ForOfStatement */)) { + if (hasKind(node.parent, 210 /* ForStatement */) || + hasKind(node.parent, 211 /* ForInStatement */) || + hasKind(node.parent, 212 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 105 /* WhileKeyword */: case 80 /* DoKeyword */: - if (hasKind(node.parent, 206 /* WhileStatement */) || hasKind(node.parent, 205 /* DoStatement */)) { + if (hasKind(node.parent, 209 /* WhileStatement */) || hasKind(node.parent, 208 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; case 122 /* ConstructorKeyword */: - if (hasKind(node.parent, 149 /* Constructor */)) { + if (hasKind(node.parent, 150 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; case 124 /* GetKeyword */: - case 132 /* SetKeyword */: - if (hasKind(node.parent, 150 /* GetAccessor */) || hasKind(node.parent, 151 /* SetAccessor */)) { + case 133 /* SetKeyword */: + if (hasKind(node.parent, 151 /* GetAccessor */) || hasKind(node.parent, 152 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } break; default: if (ts.isModifierKind(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 201 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 204 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -65666,10 +67702,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 216 /* ThrowStatement */) { + if (node.kind === 219 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 217 /* TryStatement */) { + else if (node.kind === 220 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -65696,19 +67732,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_20 = child.parent; - if (ts.isFunctionBlock(parent_20) || parent_20.kind === 256 /* SourceFile */) { - return parent_20; + var parent_19 = child.parent; + if (ts.isFunctionBlock(parent_19) || parent_19.kind === 260 /* SourceFile */) { + return parent_19; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_20.kind === 217 /* TryStatement */) { - var tryStatement = parent_20; + if (parent_19.kind === 220 /* TryStatement */) { + var tryStatement = parent_19; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_20; + child = parent_19; } return undefined; } @@ -65717,7 +67753,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 211 /* BreakStatement */ || node.kind === 210 /* ContinueStatement */) { + if (node.kind === 214 /* BreakStatement */ || node.kind === 213 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -65732,16 +67768,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_1 = statement.parent; node_1; node_1 = node_1.parent) { switch (node_1.kind) { - case 214 /* SwitchStatement */: - if (statement.kind === 210 /* ContinueStatement */) { + case 217 /* SwitchStatement */: + if (statement.kind === 213 /* ContinueStatement */) { continue; } // Fall through. - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: if (!statement.label || isLabeledBy(node_1, statement.label.text)) { return node_1; } @@ -65760,24 +67796,24 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 222 /* ClassDeclaration */ || - container.kind === 193 /* ClassExpression */ || - (declaration.kind === 143 /* Parameter */ && hasKind(container, 149 /* Constructor */)))) { + if (!(container.kind === 225 /* ClassDeclaration */ || + container.kind === 196 /* ClassExpression */ || + (declaration.kind === 144 /* Parameter */ && hasKind(container, 150 /* Constructor */)))) { return undefined; } } else if (modifier === 114 /* StaticKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || container.kind === 193 /* ClassExpression */)) { + if (!(container.kind === 225 /* ClassDeclaration */ || container.kind === 196 /* ClassExpression */)) { return undefined; } } else if (modifier === 83 /* ExportKeyword */ || modifier === 123 /* DeclareKeyword */) { - if (!(container.kind === 227 /* ModuleBlock */ || container.kind === 256 /* SourceFile */)) { + if (!(container.kind === 230 /* ModuleBlock */ || container.kind === 260 /* SourceFile */)) { return undefined; } } else if (modifier === 116 /* AbstractKeyword */) { - if (!(container.kind === 222 /* ClassDeclaration */ || declaration.kind === 222 /* ClassDeclaration */)) { + if (!(container.kind === 225 /* ClassDeclaration */ || declaration.kind === 225 /* ClassDeclaration */)) { return undefined; } } @@ -65789,8 +67825,8 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: + case 230 /* ModuleBlock */: + case 260 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); @@ -65799,17 +67835,17 @@ var ts; nodes = container.statements; } break; - case 149 /* Constructor */: + case 150 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: 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. if (modifierFlag & 28 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 149 /* Constructor */ && member; + return member.kind === 150 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -65862,13 +67898,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 150 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 151 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 152 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 132 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 124 /* GetKeyword */, 133 /* SetKeyword */); }); } } } @@ -65886,7 +67922,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 87 /* ForKeyword */, 105 /* WhileKeyword */, 80 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 205 /* DoStatement */) { + if (loopNode.kind === 208 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { @@ -65907,13 +67943,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 205 /* DoStatement */: - case 206 /* WhileStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 208 /* DoStatement */: + case 209 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -65967,7 +68003,7 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 200 /* Block */))) { + if (!(func && hasKind(func.body, 203 /* Block */))) { return undefined; } var keywords = []; @@ -65983,7 +68019,7 @@ var ts; function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 204 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 207 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. @@ -65996,7 +68032,7 @@ var ts; break; } } - if (!hasKind(ifStatement.elseStatement, 204 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 207 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -66039,7 +68075,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 215 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 218 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -66273,12 +68309,12 @@ var ts; function getAliasSymbolForPropertyNameSymbol(symbol, location) { if (symbol.flags & 8388608 /* Alias */) { // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 232 /* ImportClause */); + var defaultImport = ts.getDeclarationOfKind(symbol, 235 /* ImportClause */); if (defaultImport) { return typeChecker.getAliasedSymbol(symbol); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 235 /* ImportSpecifier */ || - declaration.kind === 239 /* ExportSpecifier */) ? declaration : undefined; }); + var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 238 /* ImportSpecifier */ || + declaration.kind === 242 /* ExportSpecifier */) ? declaration : undefined; }); if (importOrExportSpecifier && // export { a } (!importOrExportSpecifier.propertyName || @@ -66286,7 +68322,7 @@ var ts; importOrExportSpecifier.propertyName === location)) { // If Import specifier -> get alias // else Export specifier -> get local target - return importOrExportSpecifier.kind === 235 /* ImportSpecifier */ ? + return importOrExportSpecifier.kind === 238 /* ImportSpecifier */ ? typeChecker.getAliasedSymbol(symbol) : typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); } @@ -66301,14 +68337,14 @@ var ts; typeChecker.getPropertySymbolOfDestructuringAssignment(location); } function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 173 /* BindingElement */); return bindingElement && - bindingElement.parent.kind === 168 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 171 /* ObjectBindingPattern */ && !bindingElement.propertyName; } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol) { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 170 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 173 /* BindingElement */); var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); } @@ -66338,14 +68374,14 @@ 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 valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 180 /* FunctionExpression */ || valueDeclaration.kind === 193 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 183 /* FunctionExpression */ || valueDeclaration.kind === 196 /* ClassExpression */)) { return valueDeclaration; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 222 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 225 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -66376,7 +68412,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 260 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -66407,8 +68443,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 4 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 4 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -66580,14 +68616,14 @@ var ts; var result = []; for (var _i = 0, _a = classSymbol.members["__constructor"].declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149 /* Constructor */); + ts.Debug.assert(decl.kind === 150 /* Constructor */); var ctrKeyword = decl.getChildAt(0); ts.Debug.assert(ctrKeyword.kind === 122 /* ConstructorKeyword */); result.push(ctrKeyword); } ts.forEachProperty(classSymbol.exports, function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 148 /* MethodDeclaration */) { + if (decl && decl.kind === 149 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { @@ -66610,7 +68646,7 @@ var ts; var result = []; for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 149 /* Constructor */); + ts.Debug.assert(decl.kind === 150 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { @@ -66652,7 +68688,7 @@ var ts; result.push(getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 254 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 257 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); } @@ -66665,24 +68701,24 @@ var ts; // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_21 = containingTypeReference.parent; - if (ts.isVariableLike(parent_21) && parent_21.type === containingTypeReference && parent_21.initializer && isImplementationExpression(parent_21.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_21.initializer)); + var parent_20 = containingTypeReference.parent; + if (ts.isVariableLike(parent_20) && parent_20.type === containingTypeReference && parent_20.initializer && isImplementationExpression(parent_20.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_20.initializer)); } - else if (ts.isFunctionLike(parent_21) && parent_21.type === containingTypeReference && parent_21.body) { - if (parent_21.body.kind === 200 /* Block */) { - ts.forEachReturnStatement(parent_21.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_20) && parent_20.type === containingTypeReference && parent_20.body) { + if (parent_20.body.kind === 203 /* Block */) { + ts.forEachReturnStatement(parent_20.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_21.body)) { - maybeAdd(getReferenceEntryFromNode(parent_21.body)); + else if (isImplementationExpression(parent_20.body)) { + maybeAdd(getReferenceEntryFromNode(parent_20.body)); } } - else if (ts.isAssertionExpression(parent_21) && isImplementationExpression(parent_21.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_21.expression)); + else if (ts.isAssertionExpression(parent_20) && isImplementationExpression(parent_20.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_20.expression)); } } } @@ -66722,12 +68758,12 @@ var ts; } function getContainingClassIfInHeritageClause(node) { if (node && node.parent) { - if (node.kind === 195 /* ExpressionWithTypeArguments */ - && node.parent.kind === 251 /* HeritageClause */ + if (node.kind === 198 /* ExpressionWithTypeArguments */ + && node.parent.kind === 254 /* HeritageClause */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; } - else if (node.kind === 70 /* Identifier */ || node.kind === 173 /* PropertyAccessExpression */) { + else if (node.kind === 70 /* Identifier */ || node.kind === 176 /* PropertyAccessExpression */) { return getContainingClassIfInHeritageClause(node.parent); } } @@ -66738,14 +68774,14 @@ var ts; */ function isImplementationExpression(node) { // Unwrap parentheses - if (node.kind === 179 /* ParenthesizedExpression */) { + if (node.kind === 182 /* ParenthesizedExpression */) { return isImplementationExpression(node.expression); } - return node.kind === 181 /* ArrowFunction */ || - node.kind === 180 /* FunctionExpression */ || - node.kind === 172 /* ObjectLiteralExpression */ || - node.kind === 193 /* ClassExpression */ || - node.kind === 171 /* ArrayLiteralExpression */; + return node.kind === 184 /* ArrowFunction */ || + node.kind === 183 /* FunctionExpression */ || + node.kind === 175 /* ObjectLiteralExpression */ || + node.kind === 196 /* ClassExpression */ || + node.kind === 174 /* ArrayLiteralExpression */; } /** * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol @@ -66794,7 +68830,7 @@ var ts; } return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 226 /* InterfaceDeclaration */) { if (parentIsInterface) { return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); } @@ -66822,13 +68858,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -66860,27 +68896,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 256 /* SourceFile */: + case 260 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 183 /* 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. @@ -66889,7 +68925,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 256 /* SourceFile */) { + if (searchSpaceNode.kind === 260 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -66923,28 +68959,28 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 193 /* ClassExpression */: - case 222 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 225 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 256 /* SourceFile */: - if (container.kind === 256 /* SourceFile */ && !ts.isExternalModule(container)) { + case 260 /* SourceFile */: + if (container.kind === 260 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -66998,7 +69034,7 @@ var ts; // Search the property symbol // for ( { property: p2 } of elems) { } var containingObjectLiteralElement = getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 254 /* ShorthandPropertyAssignment */) { + if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 257 /* ShorthandPropertyAssignment */) { var propertySymbol = getPropertySymbolOfDestructuringAssignment(location); if (propertySymbol) { result.push(propertySymbol); @@ -67046,7 +69082,7 @@ var ts; // we should include both parameter declaration symbol and property declaration symbol // Parameter Declaration symbol is only visible within function scope, so the symbol is stored in constructor.locals. // Property Declaration symbol is a member of the class, so the symbol is stored in its class Declaration.symbol.members - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 143 /* Parameter */ && + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 144 /* Parameter */ && ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { result = result.concat(typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); } @@ -67101,7 +69137,7 @@ var ts; getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 223 /* InterfaceDeclaration */) { + else if (declaration.kind === 226 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -67185,7 +69221,7 @@ var ts; }); } function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 141 /* ComputedPropertyName */) { + if (node.name.kind === 142 /* ComputedPropertyName */) { var nameExpression = node.name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression.kind)) { @@ -67267,7 +69303,7 @@ var ts; if (node.initializer) { return true; } - else if (node.kind === 219 /* VariableDeclaration */) { + else if (node.kind === 222 /* VariableDeclaration */) { var parentStatement = getParentStatementOfVariableDeclaration(node); return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } @@ -67277,18 +69313,18 @@ var ts; } else { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: return true; } } return false; } function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 201 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 220 /* VariableDeclarationList */); + if (node.parent && node.parent.parent && node.parent.parent.kind === 204 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 223 /* VariableDeclarationList */); return node.parent.parent; } } @@ -67327,10 +69363,10 @@ var ts; } var parent = node.parent; if (parent) { - if (parent.kind === 187 /* PostfixUnaryExpression */ || parent.kind === 186 /* PrefixUnaryExpression */) { + if (parent.kind === 190 /* PostfixUnaryExpression */ || parent.kind === 189 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 188 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 191 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; } @@ -67352,7 +69388,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 141 /* ComputedPropertyName */) { + if (node.parent.kind === 142 /* ComputedPropertyName */) { return isObjectLiteralPropertyDeclaration(node.parent.parent) ? node.parent.parent : undefined; } // intential fall through @@ -67363,11 +69399,11 @@ var ts; } function isObjectLiteralPropertyDeclaration(node) { switch (node.kind) { - case 253 /* PropertyAssignment */: - case 254 /* ShorthandPropertyAssignment */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 256 /* PropertyAssignment */: + case 257 /* ShorthandPropertyAssignment */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: return true; } return false; @@ -67442,7 +69478,7 @@ var ts; // if (node.kind === 70 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 235 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 234 /* NamedImports */))) { + (declaration.kind === 238 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 237 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -67451,7 +69487,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 === 254 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 257 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -67534,8 +69570,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 149 /* Constructor */) || - (!selectConstructors && (d.kind === 221 /* FunctionDeclaration */ || d.kind === 148 /* MethodDeclaration */ || d.kind === 147 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 150 /* Constructor */) || + (!selectConstructors && (d.kind === 224 /* FunctionDeclaration */ || d.kind === 149 /* MethodDeclaration */ || d.kind === 148 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -67615,7 +69651,7 @@ var ts; function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { // 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 === 254 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 257 /* ShorthandPropertyAssignment */) { var result = []; ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); return result.length > 0 ? result : undefined; @@ -67781,19 +69817,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: - case 222 /* ClassDeclaration */: - case 201 /* VariableStatement */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: + case 225 /* ClassDeclaration */: + case 204 /* VariableStatement */: break findOwner; - case 256 /* SourceFile */: + case 260 /* SourceFile */: return undefined; - case 226 /* ModuleDeclaration */: + case 229 /* 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 { }'. - if (commentOwner.parent.kind === 226 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 229 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -67834,7 +69870,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 201 /* VariableStatement */) { + if (commentOwner.kind === 204 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -67852,17 +69888,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 179 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 182 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return rightHandSide.parameters; - case 193 /* ClassExpression */: + case 196 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 149 /* Constructor */) { + if (member.kind === 150 /* Constructor */) { return member.parameters; } } @@ -67929,7 +69965,7 @@ var ts; mergeTypings(typingOptions.include); exclude = typingOptions.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { + if (projectRootPath) { possibleSearchDirs.push(projectRootPath); } searchDirs = ts.deduplicate(possibleSearchDirs); @@ -67954,9 +69990,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_48 in packageNameToTypingLocation) { - if (name_48 in inferredTypings && !inferredTypings[name_48]) { - inferredTypings[name_48] = packageNameToTypingLocation[name_48]; + for (var name_44 in packageNameToTypingLocation) { + if (name_44 in inferredTypings && !inferredTypings[name_44]) { + inferredTypings[name_44] = packageNameToTypingLocation[name_44]; } } // Remove typings that the user has added to the exclude list @@ -68094,12 +70130,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_49 in nameToDeclarations) { - var declarations = nameToDeclarations[name_49]; + for (var name_45 in nameToDeclarations) { + var declarations = nameToDeclarations[name_45]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_49); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_45); if (!matches) { continue; } @@ -68112,14 +70148,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_49); + matches = patternMatcher.getMatches(containers, name_45); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_49, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_45, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -68127,7 +70163,7 @@ var ts; // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 232 /* ImportClause */ || decl.kind === 235 /* ImportSpecifier */ || decl.kind === 230 /* ImportEqualsDeclaration */) { + if (decl.kind === 235 /* ImportClause */ || decl.kind === 238 /* ImportSpecifier */ || decl.kind === 233 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -68169,7 +70205,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 141 /* ComputedPropertyName */) { + else if (declaration.name.kind === 142 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -68190,7 +70226,7 @@ var ts; } return true; } - if (expression.kind === 173 /* PropertyAccessExpression */) { + if (expression.kind === 176 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -68203,7 +70239,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 141 /* ComputedPropertyName */) { + if (declaration.name.kind === 142 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -68356,7 +70392,7 @@ var ts; return; } switch (node.kind) { - case 149 /* Constructor */: + case 150 /* 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); @@ -68368,21 +70404,21 @@ var ts; } } break; - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 147 /* MethodSignature */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 148 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 232 /* ImportClause */: + case 235 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -68394,7 +70430,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 233 /* NamespaceImport */) { + if (namedBindings.kind === 236 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -68405,12 +70441,12 @@ var ts; } } break; - case 170 /* BindingElement */: - case 219 /* VariableDeclaration */: + case 173 /* BindingElement */: + case 222 /* VariableDeclaration */: var decl = node; - var name_50 = decl.name; - if (ts.isBindingPattern(name_50)) { - addChildrenRecursively(name_50); + var name_46 = decl.name; + if (ts.isBindingPattern(name_46)) { + addChildrenRecursively(name_46); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -68420,12 +70456,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -68435,9 +70471,9 @@ var ts; } endNode(); break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -68445,21 +70481,21 @@ var ts; } endNode(); break; - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 239 /* ExportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 154 /* IndexSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 224 /* TypeAliasDeclaration */: + case 242 /* ExportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 155 /* IndexSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 227 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDocComments, function (jsDocComment) { ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 279 /* JSDocTypedefTag */) { + if (tag.kind === 283 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -68510,14 +70546,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 226 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 229 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 226 /* ModuleDeclaration */) { + if (a.body.kind !== 229 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -68577,7 +70613,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -68585,18 +70621,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 193 /* ClassExpression */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 196 /* ClassExpression */: return getFunctionOrClassName(node); - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 226 /* ModuleDeclaration */) { + if (node.kind === 229 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -68607,16 +70643,16 @@ var ts; } } switch (node.kind) { - case 256 /* SourceFile */: + case 260 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -68624,15 +70660,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 149 /* Constructor */: + case 150 /* Constructor */: return "constructor"; - case 153 /* ConstructSignature */: + case 154 /* ConstructSignature */: return "new()"; - case 152 /* CallSignature */: + case 153 /* CallSignature */: return "()"; - case 154 /* IndexSignature */: + case 155 /* IndexSignature */: return "[]"; - case 279 /* JSDocTypedefTag */: + case 283 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -68644,7 +70680,7 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 201 /* VariableStatement */) { + if (parentNode && parentNode.kind === 204 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; if (nameIdentifier.kind === 70 /* Identifier */) { @@ -68673,24 +70709,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 225 /* EnumDeclaration */: - case 223 /* InterfaceDeclaration */: - case 226 /* ModuleDeclaration */: - case 256 /* SourceFile */: - case 224 /* TypeAliasDeclaration */: - case 279 /* JSDocTypedefTag */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 228 /* EnumDeclaration */: + case 226 /* InterfaceDeclaration */: + case 229 /* ModuleDeclaration */: + case 260 /* SourceFile */: + case 227 /* TypeAliasDeclaration */: + case 283 /* JSDocTypedefTag */: return true; - case 149 /* Constructor */: - case 148 /* MethodDeclaration */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 219 /* VariableDeclaration */: + case 150 /* Constructor */: + case 149 /* MethodDeclaration */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 222 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 181 /* ArrowFunction */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -68700,10 +70736,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 227 /* ModuleBlock */: - case 256 /* SourceFile */: - case 148 /* MethodDeclaration */: - case 149 /* Constructor */: + case 230 /* ModuleBlock */: + case 260 /* SourceFile */: + case 149 /* MethodDeclaration */: + case 150 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -68712,7 +70748,7 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 219 /* VariableDeclaration */ && childKind !== 170 /* BindingElement */; + return childKind !== 222 /* VariableDeclaration */ && childKind !== 173 /* BindingElement */; }); } } @@ -68770,7 +70806,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 226 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 229 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -68781,13 +70817,13 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 226 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 229 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 141 /* ComputedPropertyName */; + return !member.name || member.name.kind === 142 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 256 /* SourceFile */ + return node.kind === 260 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(curSourceFile), node.getEnd()); } @@ -68795,14 +70831,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 219 /* VariableDeclaration */) { + else if (node.parent.kind === 222 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 188 /* BinaryExpression */ && + else if (node.parent.kind === 191 /* BinaryExpression */ && node.parent.operatorToken.kind === 57 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 253 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 256 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -68813,7 +70849,7 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 180 /* FunctionExpression */ || node.kind === 181 /* ArrowFunction */ || node.kind === 193 /* ClassExpression */; + return node.kind === 183 /* FunctionExpression */ || node.kind === 184 /* ArrowFunction */ || node.kind === 196 /* ClassExpression */; } /** * Matches all whitespace characters in a string. Eg: @@ -68903,7 +70939,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 181 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 184 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -68915,30 +70951,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 200 /* Block */: + case 203 /* Block */: if (!ts.isFunctionBlock(n)) { - var parent_22 = n.parent; + var parent_21 = n.parent; var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent_22.kind === 205 /* DoStatement */ || - parent_22.kind === 208 /* ForInStatement */ || - parent_22.kind === 209 /* ForOfStatement */ || - parent_22.kind === 207 /* ForStatement */ || - parent_22.kind === 204 /* IfStatement */ || - parent_22.kind === 206 /* WhileStatement */ || - parent_22.kind === 213 /* WithStatement */ || - parent_22.kind === 252 /* CatchClause */) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + if (parent_21.kind === 208 /* DoStatement */ || + parent_21.kind === 211 /* ForInStatement */ || + parent_21.kind === 212 /* ForOfStatement */ || + parent_21.kind === 210 /* ForStatement */ || + parent_21.kind === 207 /* IfStatement */ || + parent_21.kind === 209 /* WhileStatement */ || + parent_21.kind === 216 /* WithStatement */ || + parent_21.kind === 255 /* CatchClause */) { + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_22.kind === 217 /* TryStatement */) { + if (parent_21.kind === 220 /* TryStatement */) { // Could be the try-block, or the finally-block. - var tryStatement = parent_22; + var tryStatement = parent_21; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_22, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_21, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -68961,23 +70997,23 @@ var ts; break; } // Fallthrough. - case 227 /* ModuleBlock */: { + case 230 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 172 /* ObjectLiteralExpression */: - case 228 /* CaseBlock */: { + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 175 /* ObjectLiteralExpression */: + case 231 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -68997,13 +71033,13 @@ var ts; var ts; (function (ts) { // Note(cyrusn): this enum is ordered from strongest match type to weakest match type. + var PatternMatchKind; (function (PatternMatchKind) { PatternMatchKind[PatternMatchKind["exact"] = 0] = "exact"; PatternMatchKind[PatternMatchKind["prefix"] = 1] = "prefix"; PatternMatchKind[PatternMatchKind["substring"] = 2] = "substring"; PatternMatchKind[PatternMatchKind["camelCase"] = 3] = "camelCase"; - })(ts.PatternMatchKind || (ts.PatternMatchKind = {})); - var PatternMatchKind = ts.PatternMatchKind; + })(PatternMatchKind = ts.PatternMatchKind || (ts.PatternMatchKind = {})); function createPatternMatch(kind, punctuationStripped, isCaseSensitive, camelCaseWeight) { return { kind: kind, @@ -69334,7 +71370,7 @@ var ts; if (ch >= 65 /* A */ && ch <= 90 /* Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 5 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -69347,7 +71383,7 @@ var ts; if (ch >= 97 /* a */ && ch <= 122 /* z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 4 /* Latest */)) { + if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 5 /* Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -69625,7 +71661,7 @@ var ts; if (token === 123 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 126 /* ModuleKeyword */) { + if (token === 127 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -69650,7 +71686,7 @@ var ts; else { if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -69681,7 +71717,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -69697,7 +71733,7 @@ var ts; token = nextToken(); if (token === 70 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -69727,7 +71763,7 @@ var ts; } if (token === 17 /* CloseBraceToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -69739,7 +71775,7 @@ var ts; } else if (token === 38 /* AsteriskToken */) { token = nextToken(); - if (token === 137 /* FromKeyword */) { + if (token === 138 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -69764,7 +71800,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 130 /* RequireKeyword */) { + if (token === 131 /* RequireKeyword */) { token = nextToken(); if (token === 18 /* OpenParenToken */) { token = nextToken(); @@ -70119,12 +72155,12 @@ var ts; // return null; // } var emptyArray = []; + var ArgumentListKind; (function (ArgumentListKind) { ArgumentListKind[ArgumentListKind["TypeArguments"] = 0] = "TypeArguments"; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; - })(SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); - var ArgumentListKind = SignatureHelp.ArgumentListKind; + })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -70155,7 +72191,7 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 175 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 178 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. @@ -70163,7 +72199,7 @@ var ts; var expression = callExpression.expression; var name = expression.kind === 70 /* Identifier */ ? expression - : expression.kind === 173 /* PropertyAccessExpression */ + : expression.kind === 176 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -70196,7 +72232,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 175 /* CallExpression */ || node.parent.kind === 176 /* NewExpression */) { + if (node.parent.kind === 178 /* CallExpression */ || node.parent.kind === 179 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -70250,25 +72286,25 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 180 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 180 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 193 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 198 /* TemplateSpan */ && node.parent.parent.parent.kind === 177 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 201 /* TemplateSpan */ && node.parent.parent.parent.kind === 180 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 190 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 193 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -70386,7 +72422,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 === 190 /* TemplateExpression */) { + if (template.kind === 193 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -70395,7 +72431,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 256 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 260 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -70455,7 +72491,9 @@ var ts; if (callTargetDisplayParts) { ts.addRange(prefixDisplayParts, callTargetDisplayParts); } + var isVariadic; if (isTypeParameterList) { + isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; @@ -70466,6 +72504,7 @@ var ts; ts.addRange(suffixDisplayParts, parameterParts); } else { + isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); @@ -70480,7 +72519,7 @@ var ts; }); ts.addRange(suffixDisplayParts, returnTypeParts); return { - isVariadic: candidateSignature.hasRestParameter, + isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], @@ -70537,7 +72576,7 @@ var ts; function getSymbolKind(typeChecker, symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 196 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -70643,7 +72682,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 173 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 176 /* 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)) { @@ -70652,7 +72691,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression = void 0; - if (location.kind === 175 /* CallExpression */ || location.kind === 176 /* NewExpression */) { + if (location.kind === 178 /* CallExpression */ || location.kind === 179 /* NewExpression */) { callExpression = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -70665,7 +72704,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 176 /* NewExpression */ || callExpression.expression.kind === 96 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 179 /* NewExpression */ || callExpression.expression.kind === 96 /* 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 @@ -70718,24 +72757,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 149 /* Constructor */)) { + (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 150 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 149 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 150 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 149 /* Constructor */) { + if (functionDeclaration.kind === 150 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 152 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 153 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -70744,7 +72783,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 193 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 196 /* 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 @@ -70767,7 +72806,7 @@ var ts; } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -70788,9 +72827,9 @@ var ts; } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 226 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 229 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 127 /* NamespaceKeyword */ : 126 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -70811,17 +72850,17 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 142 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 143 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 153 /* ConstructSignature */) { + if (declaration.kind === 154 /* ConstructSignature */) { displayParts.push(ts.keywordPart(93 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 152 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 153 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -70830,7 +72869,7 @@ var ts; // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path - displayParts.push(ts.keywordPart(135 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(136 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -70841,7 +72880,7 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 255 /* EnumMember */) { + if (declaration.kind === 259 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -70853,10 +72892,10 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 229 /* NamespaceExportDeclaration */) { + if (symbol.declarations[0].kind === 232 /* NamespaceExportDeclaration */) { displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(127 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); } else { displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); @@ -70864,13 +72903,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 230 /* ImportEqualsDeclaration */) { + if (declaration.kind === 233 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(57 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(130 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(131 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); @@ -70937,10 +72976,10 @@ var ts; // For some special property access expressions like `experts.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 === 256 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 260 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 188 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 191 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -71016,16 +73055,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 180 /* FunctionExpression */) { + if (declaration.kind === 183 /* FunctionExpression */) { return true; } - if (declaration.kind !== 219 /* VariableDeclaration */ && declaration.kind !== 221 /* FunctionDeclaration */) { + if (declaration.kind !== 222 /* VariableDeclaration */ && declaration.kind !== 224 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable - for (var parent_23 = declaration.parent; !ts.isFunctionBlock(parent_23); parent_23 = parent_23.parent) { + for (var parent_22 = declaration.parent; !ts.isFunctionBlock(parent_22); parent_22 = parent_22.parent) { // Reached source file or module block - if (parent_23.kind === 256 /* SourceFile */ || parent_23.kind === 227 /* ModuleBlock */) { + if (parent_22.kind === 260 /* SourceFile */ || parent_22.kind === 230 /* ModuleBlock */) { return false; } } @@ -71136,7 +73175,7 @@ var ts; return typeof o.type === "object" && !ts.forEachProperty(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.clone(options); - var _loop_3 = function (opt) { + var _loop_4 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -71155,7 +73194,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_3(opt); + _loop_4(opt); } return options; } @@ -71167,8 +73206,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(4 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + var jsxScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); /** * Scanner that is currently used for formatting */ @@ -71263,10 +73302,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 246 /* JsxAttribute */: - case 244 /* JsxOpeningElement */: - case 245 /* JsxClosingElement */: - case 243 /* JsxSelfClosingElement */: + case 249 /* JsxAttribute */: + case 247 /* JsxOpeningElement */: + case 248 /* JsxClosingElement */: + case 246 /* JsxSelfClosingElement */: return node.kind === 70 /* Identifier */; } } @@ -71501,14 +73540,14 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var FormattingRequestKind; (function (FormattingRequestKind) { FormattingRequestKind[FormattingRequestKind["FormatDocument"] = 0] = "FormatDocument"; FormattingRequestKind[FormattingRequestKind["FormatSelection"] = 1] = "FormatSelection"; FormattingRequestKind[FormattingRequestKind["FormatOnEnter"] = 2] = "FormatOnEnter"; FormattingRequestKind[FormattingRequestKind["FormatOnSemicolon"] = 3] = "FormatOnSemicolon"; FormattingRequestKind[FormattingRequestKind["FormatOnClosingCurlyBrace"] = 4] = "FormatOnClosingCurlyBrace"; - })(formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); - var FormattingRequestKind = formatting.FormattingRequestKind; + })(FormattingRequestKind = formatting.FormattingRequestKind || (formatting.FormattingRequestKind = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71540,13 +73579,13 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var RuleAction; (function (RuleAction) { RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; RuleAction[RuleAction["Space"] = 2] = "Space"; RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; RuleAction[RuleAction["Delete"] = 8] = "Delete"; - })(formatting.RuleAction || (formatting.RuleAction = {})); - var RuleAction = formatting.RuleAction; + })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71587,11 +73626,11 @@ var ts; (function (ts) { var formatting; (function (formatting) { + var RuleFlags; (function (RuleFlags) { RuleFlags[RuleFlags["None"] = 0] = "None"; RuleFlags[RuleFlags["CanDeleteNewLines"] = 1] = "CanDeleteNewLines"; - })(formatting.RuleFlags || (formatting.RuleFlags = {})); - var RuleFlags = formatting.RuleFlags; + })(RuleFlags = formatting.RuleFlags || (formatting.RuleFlags = {})); })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); /// @@ -71742,7 +73781,7 @@ var ts; this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 132 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124 /* GetKeyword */, 133 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); @@ -71750,10 +73789,10 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([126 /* ModuleKeyword */, 130 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 126 /* ModuleKeyword */, 127 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 132 /* SetKeyword */, 114 /* StaticKeyword */, 135 /* TypeKeyword */, 137 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 137 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 133 /* SetKeyword */, 114 /* StaticKeyword */, 136 /* TypeKeyword */, 138 /* FromKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 138 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions @@ -71773,7 +73812,7 @@ var ts; // decorators this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 132 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 133 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); @@ -71901,9 +73940,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_51 in o) { - if (o[name_51] === rule) { - return name_51; + for (var name_47 in o) { + if (o[name_47] === rule) { + return name_47; } } throw new Error("Unknown rule"); @@ -71912,42 +73951,42 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 207 /* ForStatement */; + return context.contextNode.kind === 210 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 188 /* BinaryExpression */: - case 189 /* ConditionalExpression */: - case 196 /* AsExpression */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: - case 155 /* TypePredicate */: - case 163 /* UnionType */: - case 164 /* IntersectionType */: + case 191 /* BinaryExpression */: + case 192 /* ConditionalExpression */: + case 199 /* AsExpression */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 156 /* TypePredicate */: + case 164 /* UnionType */: + case 165 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 170 /* BindingElement */: + case 173 /* BindingElement */: // equals in type X = ... - case 224 /* TypeAliasDeclaration */: + case 227 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 219 /* VariableDeclaration */: + case 222 /* VariableDeclaration */: // equal in p = 0; - case 143 /* Parameter */: - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 144 /* Parameter */: + case 259 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 209 /* ForOfStatement */: - return context.currentTokenSpan.kind === 139 /* OfKeyword */ || context.nextTokenSpan.kind === 139 /* OfKeyword */; + case 212 /* ForOfStatement */: + return context.currentTokenSpan.kind === 140 /* OfKeyword */ || context.nextTokenSpan.kind === 140 /* OfKeyword */; } return false; }; @@ -71955,7 +73994,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 189 /* ConditionalExpression */; + return context.contextNode.kind === 192 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -71999,97 +74038,97 @@ var ts; return true; } switch (node.kind) { - case 200 /* Block */: - case 228 /* CaseBlock */: - case 172 /* ObjectLiteralExpression */: - case 227 /* ModuleBlock */: + case 203 /* Block */: + case 231 /* CaseBlock */: + case 175 /* ObjectLiteralExpression */: + case 230 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 152 /* CallSignature */: - case 180 /* FunctionExpression */: - case 149 /* Constructor */: - case 181 /* ArrowFunction */: + case 153 /* CallSignature */: + case 183 /* FunctionExpression */: + case 150 /* Constructor */: + case 184 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 223 /* InterfaceDeclaration */: + case 226 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 221 /* FunctionDeclaration */ || context.contextNode.kind === 180 /* FunctionExpression */; + return context.contextNode.kind === 224 /* FunctionDeclaration */ || context.contextNode.kind === 183 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 160 /* TypeLiteral */: - case 226 /* ModuleDeclaration */: - case 237 /* ExportDeclaration */: - case 238 /* NamedExports */: - case 231 /* ImportDeclaration */: - case 234 /* NamedImports */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 161 /* TypeLiteral */: + case 229 /* ModuleDeclaration */: + case 240 /* ExportDeclaration */: + case 241 /* NamedExports */: + case 234 /* ImportDeclaration */: + case 237 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 222 /* ClassDeclaration */: - case 226 /* ModuleDeclaration */: - case 225 /* EnumDeclaration */: - case 200 /* Block */: - case 252 /* CatchClause */: - case 227 /* ModuleBlock */: - case 214 /* SwitchStatement */: + case 225 /* ClassDeclaration */: + case 229 /* ModuleDeclaration */: + case 228 /* EnumDeclaration */: + case 203 /* Block */: + case 255 /* CatchClause */: + case 230 /* ModuleBlock */: + case 217 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 204 /* IfStatement */: - case 214 /* SwitchStatement */: - case 207 /* ForStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 206 /* WhileStatement */: - case 217 /* TryStatement */: - case 205 /* DoStatement */: - case 213 /* WithStatement */: + case 207 /* IfStatement */: + case 217 /* SwitchStatement */: + case 210 /* ForStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 209 /* WhileStatement */: + case 220 /* TryStatement */: + case 208 /* DoStatement */: + case 216 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 252 /* CatchClause */: + case 255 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 172 /* ObjectLiteralExpression */; + return context.contextNode.kind === 175 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 175 /* CallExpression */; + return context.contextNode.kind === 178 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 176 /* NewExpression */; + return context.contextNode.kind === 179 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -72101,25 +74140,25 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 181 /* ArrowFunction */; + return context.contextNode.kind === 184 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 242 /* JsxElement */; + return context.contextNode.kind !== 245 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 248 /* JsxExpression */; + return context.contextNode.kind === 251 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 246 /* JsxAttribute */; + return context.nextTokenParent.kind === 249 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 246 /* JsxAttribute */; + return context.contextNode.kind === 249 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 243 /* JsxSelfClosingElement */; + return context.contextNode.kind === 246 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -72134,41 +74173,41 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 144 /* Decorator */; + return node.kind === 145 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 220 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 223 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 226 /* ModuleDeclaration */; + return context.contextNode.kind === 229 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 160 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 161 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 156 /* TypeReference */: - case 178 /* TypeAssertionExpression */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 195 /* ExpressionWithTypeArguments */: + case 157 /* TypeReference */: + case 181 /* TypeAssertionExpression */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 198 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -72179,13 +74218,13 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 178 /* TypeAssertionExpression */; + return context.contextNode.kind === 181 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 184 /* VoidExpression */; + return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 187 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 191 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 194 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; }()); @@ -72209,7 +74248,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 139 /* LastToken */ + 1; + this.mapRowLength = 140 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); // new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); // new Array(this.map.length); @@ -72223,7 +74262,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 139 /* LastKeyword */ && column <= 139 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 140 /* LastKeyword */ && column <= 140 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -72260,6 +74299,7 @@ var ts; formatting.RulesMap = RulesMap; var MaskBitSize = 5; var Mask = 0x1f; + var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; RulesPosition[RulesPosition["IgnoreRulesAny"] = MaskBitSize * 1] = "IgnoreRulesAny"; @@ -72267,8 +74307,7 @@ var ts; RulesPosition[RulesPosition["ContextRulesAny"] = MaskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = MaskBitSize * 4] = "NoContextRulesSpecific"; RulesPosition[RulesPosition["NoContextRulesAny"] = MaskBitSize * 5] = "NoContextRulesAny"; - })(formatting.RulesPosition || (formatting.RulesPosition = {})); - var RulesPosition = formatting.RulesPosition; + })(RulesPosition = formatting.RulesPosition || (formatting.RulesPosition = {})); var RulesBucketConstructionState = (function () { function RulesBucketConstructionState() { //// The Rules list contains all the inserted rules into a rulebucket in the following order: @@ -72404,7 +74443,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 139 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 140 /* LastToken */; token++) { result.push(token); } return result; @@ -72448,9 +74487,9 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 139 /* LastKeyword */); + TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 140 /* LastKeyword */); TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 139 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 140 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); @@ -72458,7 +74497,7 @@ var ts; TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 131 /* NumberKeyword */, 133 /* StringKeyword */, 121 /* BooleanKeyword */, 134 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 134 /* StringKeyword */, 121 /* BooleanKeyword */, 135 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -72717,17 +74756,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 222 /* ClassDeclaration */: - case 223 /* InterfaceDeclaration */: + case 225 /* ClassDeclaration */: + case 226 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 227 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 256 /* SourceFile */: - case 200 /* Block */: - case 227 /* ModuleBlock */: + return body && body.kind === 230 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 260 /* SourceFile */: + case 203 /* Block */: + case 230 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -72932,20 +74971,20 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 222 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 223 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 221 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 225 /* EnumDeclaration */: return 225 /* EnumDeclaration */; - case 150 /* GetAccessor */: return 124 /* GetKeyword */; - case 151 /* SetAccessor */: return 132 /* SetKeyword */; - case 148 /* MethodDeclaration */: + case 225 /* ClassDeclaration */: return 74 /* ClassKeyword */; + case 226 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; + case 224 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; + case 228 /* EnumDeclaration */: return 228 /* EnumDeclaration */; + case 151 /* GetAccessor */: return 124 /* GetKeyword */; + case 152 /* SetAccessor */: return 133 /* SetKeyword */; + case 149 /* MethodDeclaration */: if (node.asteriskToken) { return 38 /* AsteriskToken */; } /* fall-through */ - case 146 /* PropertyDeclaration */: - case 143 /* Parameter */: + case 147 /* PropertyDeclaration */: + case 144 /* Parameter */: return node.name.kind; } } @@ -73089,11 +75128,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 144 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 145 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 171 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 174 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -73438,12 +75477,12 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 149 /* Constructor */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 181 /* ArrowFunction */: + case 150 /* Constructor */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 184 /* ArrowFunction */: if (node.typeParameters === list) { return 26 /* LessThanToken */; } @@ -73451,8 +75490,8 @@ var ts; return 18 /* OpenParenToken */; } break; - case 175 /* CallExpression */: - case 176 /* NewExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73460,7 +75499,7 @@ var ts; return 18 /* OpenParenToken */; } break; - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.typeArguments === list) { return 26 /* LessThanToken */; } @@ -73576,7 +75615,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 188 /* BinaryExpression */) { + if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 191 /* 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 */) { @@ -73699,7 +75738,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 === 256 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 260 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -73732,7 +75771,7 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 204 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 207 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -73744,23 +75783,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 156 /* TypeReference */: + case 157 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 172 /* ObjectLiteralExpression */: + case 175 /* ObjectLiteralExpression */: return node.parent.properties; - case 171 /* ArrayLiteralExpression */: + case 174 /* ArrayLiteralExpression */: return node.parent.elements; - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: { + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -73771,8 +75810,8 @@ var ts; } break; } - case 176 /* NewExpression */: - case 175 /* CallExpression */: { + case 179 /* NewExpression */: + case 178 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -73802,8 +75841,8 @@ var ts; if (node.kind === 19 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 175 /* CallExpression */ || - node.parent.kind === 176 /* NewExpression */) && + if (node.parent && (node.parent.kind === 178 /* CallExpression */ || + node.parent.kind === 179 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -73821,10 +75860,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 173 /* PropertyAccessExpression */: - case 174 /* ElementAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 176 /* PropertyAccessExpression */: + case 177 /* ElementAccessExpression */: node = node.expression; break; default: @@ -73888,48 +75927,48 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 203 /* ExpressionStatement */: - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 225 /* EnumDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 171 /* ArrayLiteralExpression */: - case 200 /* Block */: - case 227 /* ModuleBlock */: - case 172 /* ObjectLiteralExpression */: - case 160 /* TypeLiteral */: - case 162 /* TupleType */: - case 228 /* CaseBlock */: - case 250 /* DefaultClause */: - case 249 /* CaseClause */: - case 179 /* ParenthesizedExpression */: - case 173 /* PropertyAccessExpression */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 201 /* VariableStatement */: - case 219 /* VariableDeclaration */: - case 236 /* ExportAssignment */: - case 212 /* ReturnStatement */: - case 189 /* ConditionalExpression */: - case 169 /* ArrayBindingPattern */: - case 168 /* ObjectBindingPattern */: - case 244 /* JsxOpeningElement */: - case 243 /* JsxSelfClosingElement */: - case 248 /* JsxExpression */: - case 147 /* MethodSignature */: - case 152 /* CallSignature */: - case 153 /* ConstructSignature */: - case 143 /* Parameter */: - case 157 /* FunctionType */: - case 158 /* ConstructorType */: - case 165 /* ParenthesizedType */: - case 177 /* TaggedTemplateExpression */: - case 185 /* AwaitExpression */: - case 238 /* NamedExports */: - case 234 /* NamedImports */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: + case 206 /* ExpressionStatement */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 228 /* EnumDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 174 /* ArrayLiteralExpression */: + case 203 /* Block */: + case 230 /* ModuleBlock */: + case 175 /* ObjectLiteralExpression */: + case 161 /* TypeLiteral */: + case 163 /* TupleType */: + case 231 /* CaseBlock */: + case 253 /* DefaultClause */: + case 252 /* CaseClause */: + case 182 /* ParenthesizedExpression */: + case 176 /* PropertyAccessExpression */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 204 /* VariableStatement */: + case 222 /* VariableDeclaration */: + case 239 /* ExportAssignment */: + case 215 /* ReturnStatement */: + case 192 /* ConditionalExpression */: + case 172 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 247 /* JsxOpeningElement */: + case 246 /* JsxSelfClosingElement */: + case 251 /* JsxExpression */: + case 148 /* MethodSignature */: + case 153 /* CallSignature */: + case 154 /* ConstructSignature */: + case 144 /* Parameter */: + case 158 /* FunctionType */: + case 159 /* ConstructorType */: + case 166 /* ParenthesizedType */: + case 180 /* TaggedTemplateExpression */: + case 188 /* AwaitExpression */: + case 241 /* NamedExports */: + case 237 /* NamedImports */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: return true; } return false; @@ -73938,27 +75977,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 205 /* DoStatement */: - case 206 /* WhileStatement */: - case 208 /* ForInStatement */: - case 209 /* ForOfStatement */: - case 207 /* ForStatement */: - case 204 /* IfStatement */: - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 181 /* ArrowFunction */: - case 149 /* Constructor */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - return childKind !== 200 /* Block */; - case 237 /* ExportDeclaration */: - return childKind !== 238 /* NamedExports */; - case 231 /* ImportDeclaration */: - return childKind !== 232 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 234 /* NamedImports */); - case 242 /* JsxElement */: - return childKind !== 245 /* JsxClosingElement */; + case 208 /* DoStatement */: + case 209 /* WhileStatement */: + case 211 /* ForInStatement */: + case 212 /* ForOfStatement */: + case 210 /* ForStatement */: + case 207 /* IfStatement */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 184 /* ArrowFunction */: + case 150 /* Constructor */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + return childKind !== 203 /* Block */; + case 240 /* ExportDeclaration */: + return childKind !== 241 /* NamedExports */; + case 234 /* ImportDeclaration */: + return childKind !== 235 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 237 /* NamedImports */); + case 245 /* JsxElement */: + return childKind !== 248 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -74048,7 +76087,7 @@ var ts; } // figure out if the this access is actuall inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 175 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind == 178 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -74072,7 +76111,7 @@ var ts; changes: changes }]; function findSuperCall(n) { - if (n.kind === 203 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 206 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -74117,7 +76156,7 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 140 /* FirstNode */ ? new NodeObject(kind, pos, end) : + var node = kind >= 141 /* FirstNode */ ? new NodeObject(kind, pos, end) : kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; @@ -74175,11 +76214,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(286 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(290 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -74194,11 +76233,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 140 /* FirstNode */) { + if (this.kind >= 141 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 273 /* FirstJSDocTagNode */ && this.kind <= 285 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 277 /* FirstJSDocTagNode */ && this.kind <= 289 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -74256,7 +76295,7 @@ var ts; return undefined; } var child = children[0]; - return child.kind < 140 /* FirstNode */ ? child : child.getFirstToken(sourceFile); + return child.kind < 141 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; NodeObject.prototype.getLastToken = function (sourceFile) { var children = this.getChildren(sourceFile); @@ -74264,7 +76303,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 140 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 141 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; return NodeObject; }()); @@ -74467,9 +76506,9 @@ var ts; if (result_6 !== undefined) { return result_6; } - if (declaration.name.kind === 141 /* ComputedPropertyName */) { + if (declaration.name.kind === 142 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 173 /* PropertyAccessExpression */) { + if (expr.kind === 176 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -74489,10 +76528,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 221 /* FunctionDeclaration */: - case 180 /* FunctionExpression */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: + case 224 /* FunctionDeclaration */: + case 183 /* FunctionExpression */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -74512,32 +76551,32 @@ var ts; ts.forEachChild(node, visit); } break; - case 222 /* ClassDeclaration */: - case 193 /* ClassExpression */: - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: - case 225 /* EnumDeclaration */: - case 226 /* ModuleDeclaration */: - case 230 /* ImportEqualsDeclaration */: - case 239 /* ExportSpecifier */: - case 235 /* ImportSpecifier */: - case 230 /* ImportEqualsDeclaration */: - case 232 /* ImportClause */: - case 233 /* NamespaceImport */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 160 /* TypeLiteral */: + case 225 /* ClassDeclaration */: + case 196 /* ClassExpression */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: + case 228 /* EnumDeclaration */: + case 229 /* ModuleDeclaration */: + case 233 /* ImportEqualsDeclaration */: + case 242 /* ExportSpecifier */: + case 238 /* ImportSpecifier */: + case 233 /* ImportEqualsDeclaration */: + case 235 /* ImportClause */: + case 236 /* NamespaceImport */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 161 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 143 /* Parameter */: + case 144 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // fall through - case 219 /* VariableDeclaration */: - case 170 /* BindingElement */: { + case 222 /* VariableDeclaration */: + case 173 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -74546,19 +76585,19 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 255 /* EnumMember */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 259 /* EnumMember */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: addDeclaration(node); break; - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -74570,7 +76609,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 233 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 236 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -74725,7 +76764,7 @@ var ts; var sourceFile; if (this.currentFileName !== fileName) { // This is a new file, just parse it - sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 4 /* Latest */, version, /*setNodeParents*/ true, scriptKind); + sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 5 /* Latest */, version, /*setNodeParents*/ true, scriptKind); } else if (this.currentFileVersion !== version) { // This is the same file, just a newer version. Incrementally parse the file. @@ -75100,10 +77139,10 @@ var ts; // Try getting just type at this position and show switch (node.kind) { case 70 /* Identifier */: - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: case 98 /* ThisKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: case 96 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); @@ -75246,15 +77285,15 @@ var ts; return; } switch (node.kind) { - case 173 /* PropertyAccessExpression */: - case 140 /* QualifiedName */: + case 176 /* PropertyAccessExpression */: + case 141 /* QualifiedName */: case 9 /* StringLiteral */: case 85 /* FalseKeyword */: case 100 /* TrueKeyword */: case 94 /* NullKeyword */: case 96 /* SuperKeyword */: case 98 /* ThisKeyword */: - case 166 /* ThisType */: + case 167 /* ThisType */: case 70 /* Identifier */: break; // Cant create the text span @@ -75271,7 +77310,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 === 226 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 229 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -75655,7 +77694,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 241 /* ExternalModuleReference */ || + node.parent.kind === 244 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { nameTable[node.text] = nameTable[node.text] === undefined ? node.pos : -1; @@ -75675,7 +77714,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 174 /* ElementAccessExpression */ && + node.parent.kind === 177 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -75759,113 +77798,113 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 201 /* VariableStatement */: + case 204 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 219 /* VariableDeclaration */: - case 146 /* PropertyDeclaration */: - case 145 /* PropertySignature */: + case 222 /* VariableDeclaration */: + case 147 /* PropertyDeclaration */: + case 146 /* PropertySignature */: return spanInVariableDeclaration(node); - case 143 /* Parameter */: + case 144 /* Parameter */: return spanInParameterDeclaration(node); - case 221 /* FunctionDeclaration */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 180 /* FunctionExpression */: - case 181 /* ArrowFunction */: + case 224 /* FunctionDeclaration */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 183 /* FunctionExpression */: + case 184 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 200 /* Block */: + case 203 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: return spanInBlock(node); - case 252 /* CatchClause */: + case 255 /* CatchClause */: return spanInBlock(node.block); - case 203 /* ExpressionStatement */: + case 206 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 212 /* ReturnStatement */: + case 215 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 206 /* WhileStatement */: + case 209 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 205 /* DoStatement */: + case 208 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 218 /* DebuggerStatement */: + case 221 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 204 /* IfStatement */: + case 207 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 215 /* LabeledStatement */: + case 218 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 211 /* BreakStatement */: - case 210 /* ContinueStatement */: + case 214 /* BreakStatement */: + case 213 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 207 /* ForStatement */: + case 210 /* ForStatement */: return spanInForStatement(node); - case 208 /* ForInStatement */: + case 211 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 209 /* ForOfStatement */: + case 212 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 214 /* SwitchStatement */: + case 217 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 249 /* CaseClause */: - case 250 /* DefaultClause */: + case 252 /* CaseClause */: + case 253 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 217 /* TryStatement */: + case 220 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 216 /* ThrowStatement */: + case 219 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 236 /* ExportAssignment */: + case 239 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 230 /* ImportEqualsDeclaration */: + case 233 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 231 /* ImportDeclaration */: + case 234 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 237 /* ExportDeclaration */: + case 240 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 222 /* ClassDeclaration */: - case 225 /* EnumDeclaration */: - case 255 /* EnumMember */: - case 170 /* BindingElement */: + case 225 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 259 /* EnumMember */: + case 173 /* BindingElement */: // span on complete node return textSpan(node); - case 213 /* WithStatement */: + case 216 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 144 /* Decorator */: + case 145 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 168 /* ObjectBindingPattern */: - case 169 /* ArrayBindingPattern */: + case 171 /* ObjectBindingPattern */: + case 172 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 223 /* InterfaceDeclaration */: - case 224 /* TypeAliasDeclaration */: + case 226 /* InterfaceDeclaration */: + case 227 /* TypeAliasDeclaration */: return undefined; // Tokens: case 24 /* SemicolonToken */: @@ -75895,7 +77934,7 @@ var ts; case 73 /* CatchKeyword */: case 86 /* FinallyKeyword */: return spanInNextNode(node); - case 139 /* OfKeyword */: + case 140 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -75908,13 +77947,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 === 70 /* Identifier */ || - node.kind == 192 /* SpreadElementExpression */ || - node.kind === 253 /* PropertyAssignment */ || - node.kind === 254 /* ShorthandPropertyAssignment */) && + node.kind == 195 /* SpreadElement */ || + node.kind === 256 /* PropertyAssignment */ || + node.kind === 257 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 188 /* BinaryExpression */) { + if (node.kind === 191 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -75937,22 +77976,22 @@ var ts; } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 205 /* DoStatement */: + case 208 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 144 /* Decorator */: + case 145 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 212 /* ForOfStatement */: return textSpan(node); - case 188 /* BinaryExpression */: + case 191 /* BinaryExpression */: if (node.parent.operatorToken.kind === 25 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 181 /* ArrowFunction */: + case 184 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -75961,13 +78000,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 253 /* PropertyAssignment */ && + if (node.parent.kind === 256 /* PropertyAssignment */ && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 178 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 181 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -75975,8 +78014,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 219 /* VariableDeclaration */ || - node.parent.kind === 143 /* Parameter */)) { + if ((node.parent.kind === 222 /* VariableDeclaration */ || + node.parent.kind === 144 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -75984,7 +78023,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 188 /* BinaryExpression */) { + if (node.parent.kind === 191 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -76010,7 +78049,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 208 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 211 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -76021,7 +78060,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 209 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 212 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } var declarations = variableDeclaration.parent.declarations; @@ -76061,7 +78100,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 222 /* ClassDeclaration */ && functionDeclaration.kind !== 149 /* Constructor */); + (functionDeclaration.parent.kind === 225 /* ClassDeclaration */ && functionDeclaration.kind !== 150 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -76084,25 +78123,25 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 226 /* ModuleDeclaration */: + case 229 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 206 /* WhileStatement */: - case 204 /* IfStatement */: - case 208 /* ForInStatement */: + case 209 /* WhileStatement */: + case 207 /* IfStatement */: + case 211 /* 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 207 /* ForStatement */: - case 209 /* ForOfStatement */: + case 210 /* ForStatement */: + case 212 /* 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 === 220 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 223 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -76127,23 +78166,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 197 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 170 /* BindingElement */) { + if (bindingPattern.parent.kind === 173 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 169 /* ArrayBindingPattern */ && node.kind !== 168 /* ObjectBindingPattern */); - var elements = node.kind === 171 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 172 /* ArrayBindingPattern */ && node.kind !== 171 /* ObjectBindingPattern */); + var elements = node.kind === 174 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 194 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 197 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -76151,18 +78190,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 === 188 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 191 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 225 /* EnumDeclaration */: + case 228 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 222 /* ClassDeclaration */: + case 225 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -76170,24 +78209,24 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 227 /* ModuleBlock */: + case 230 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 225 /* EnumDeclaration */: - case 222 /* ClassDeclaration */: + case 228 /* EnumDeclaration */: + case 225 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 200 /* Block */: + case 203 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through - case 252 /* CatchClause */: + case 255 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 228 /* CaseBlock */: + case 231 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -76195,7 +78234,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 168 /* ObjectBindingPattern */: + case 171 /* 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); @@ -76211,7 +78250,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 169 /* ArrayBindingPattern */: + case 172 /* 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); @@ -76226,12 +78265,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 205 /* DoStatement */ || - node.parent.kind === 175 /* CallExpression */ || - node.parent.kind === 176 /* NewExpression */) { + if (node.parent.kind === 208 /* DoStatement */ || + node.parent.kind === 178 /* CallExpression */ || + node.parent.kind === 179 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 179 /* ParenthesizedExpression */) { + if (node.parent.kind === 182 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -76240,21 +78279,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 180 /* FunctionExpression */: - case 221 /* FunctionDeclaration */: - case 181 /* ArrowFunction */: - case 148 /* MethodDeclaration */: - case 147 /* MethodSignature */: - case 150 /* GetAccessor */: - case 151 /* SetAccessor */: - case 149 /* Constructor */: - case 206 /* WhileStatement */: - case 205 /* DoStatement */: - case 207 /* ForStatement */: - case 209 /* ForOfStatement */: - case 175 /* CallExpression */: - case 176 /* NewExpression */: - case 179 /* ParenthesizedExpression */: + case 183 /* FunctionExpression */: + case 224 /* FunctionDeclaration */: + case 184 /* ArrowFunction */: + case 149 /* MethodDeclaration */: + case 148 /* MethodSignature */: + case 151 /* GetAccessor */: + case 152 /* SetAccessor */: + case 150 /* Constructor */: + case 209 /* WhileStatement */: + case 208 /* DoStatement */: + case 210 /* ForStatement */: + case 212 /* ForOfStatement */: + case 178 /* CallExpression */: + case 179 /* NewExpression */: + case 182 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -76264,20 +78303,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 253 /* PropertyAssignment */ || - node.parent.kind === 143 /* Parameter */) { + node.parent.kind === 256 /* PropertyAssignment */ || + node.parent.kind === 144 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 178 /* TypeAssertionExpression */) { + if (node.parent.kind === 181 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 205 /* DoStatement */) { + if (node.parent.kind === 208 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -76285,7 +78324,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 209 /* ForOfStatement */) { + if (node.parent.kind === 212 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -76367,7 +78406,7 @@ var ts; var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 2cd89cdc029..47c2ab085df 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -26,12 +26,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; - })(ts.ExitStatus || (ts.ExitStatus = {})); - var ExitStatus = ts.ExitStatus; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; @@ -44,19 +45,19 @@ var ts; TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 8] = "Promise"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 9] = "TypeWithCallSignature"; TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 10] = "ObjectType"; - })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); - var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; + })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var DiagnosticCategory; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; + })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); + var ModuleResolutionKind; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; - })(ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); - var ModuleResolutionKind = ts.ModuleResolutionKind; + })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); + var ModuleKind; (function (ModuleKind) { ModuleKind[ModuleKind["None"] = 0] = "None"; ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; @@ -64,8 +65,16 @@ var ts; ModuleKind[ModuleKind["UMD"] = 3] = "UMD"; ModuleKind[ModuleKind["System"] = 4] = "System"; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; + })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -204,6 +213,13 @@ var ts; return undefined; } ts.forEach = forEach; + function zipWith(arrayA, arrayB, callback) { + Debug.assert(arrayA.length === arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + callback(arrayA[i], arrayB[i], i); + } + } + ts.zipWith = zipWith; function every(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -463,20 +479,25 @@ var ts; ts.mapObject = mapObject; function some(array, predicate) { if (array) { - for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { - var v = array_5[_i]; - if (!predicate || predicate(v)) { - return true; + if (predicate) { + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + if (predicate(v)) { + return true; + } } } + else { + return array.length > 0; + } } return false; } ts.some = some; function concatenate(array1, array2) { - if (!array2 || !array2.length) + if (!some(array2)) return array1; - if (!array1 || !array1.length) + if (!some(array1)) return array2; return array1.concat(array2); } @@ -552,6 +573,26 @@ var ts; return result || array; } ts.compact = compact; + function relativeComplement(arrayA, arrayB, comparer, offsetA, offsetB) { + if (comparer === void 0) { comparer = compareValues; } + if (offsetA === void 0) { offsetA = 0; } + if (offsetB === void 0) { offsetB = 0; } + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + outer: for (; offsetB < arrayB.length; offsetB++) { + inner: for (; offsetA < arrayA.length; offsetA++) { + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1: break inner; + case 0: continue outer; + case 1: continue inner; + } + } + result.push(arrayB[offsetB]); + } + return result; + } + ts.relativeComplement = relativeComplement; function sum(array, prop) { var result = 0; for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { @@ -561,15 +602,23 @@ var ts; return result; } ts.sum = sum; + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + to = []; + to.push(value); + return to; + } + ts.append = append; function addRange(to, from) { - if (to && from) { - for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { - var v = from_1[_i]; - if (v !== undefined) { - to.push(v); - } - } + if (from === undefined) + return to; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; + to = append(to, v); } + return to; } ts.addRange = addRange; function rangeEquals(array1, array2, pos, end) { @@ -588,6 +637,12 @@ var ts; : undefined; } ts.firstOrUndefined = firstOrUndefined; + function lastOrUndefined(array) { + return array && array.length > 0 + ? array[array.length - 1] + : undefined; + } + ts.lastOrUndefined = lastOrUndefined; function singleOrUndefined(array) { return array && array.length === 1 ? array[0] @@ -600,23 +655,17 @@ var ts; : array; } ts.singleOrMany = singleOrMany; - function lastOrUndefined(array) { - return array && array.length > 0 - ? array[array.length - 1] - : undefined; - } - ts.lastOrUndefined = lastOrUndefined; function replaceElement(array, index, value) { var result = array.slice(0); result[index] = value; return result; } ts.replaceElement = replaceElement; - function binarySearch(array, value, comparer) { + function binarySearch(array, value, comparer, offset) { if (!array || array.length === 0) { return -1; } - var low = 0; + var low = offset || 0; var high = array.length - 1; comparer = comparer !== undefined ? comparer @@ -1374,6 +1423,10 @@ var ts; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; } ts.endsWith = endsWith; + function hasExtension(fileName) { + return getBaseFileName(fileName).indexOf(".") >= 0; + } + ts.hasExtension = hasExtension; function fileExtensionIs(path, extension) { return path.length > extension.length && endsWith(path, extension); } @@ -1401,68 +1454,83 @@ var ts; var doubleAsteriskRegexFragment = usage === "exclude" ? "(/.+?)?" : "(/[^/.][^/]*)*?"; var pattern = ""; var hasWrittenSubpattern = false; - spec: for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { + for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) { var spec = specs_1[_i]; if (!spec) { continue; } - var subpattern = ""; - var hasRecursiveDirectoryWildcard = false; - var hasWrittenComponent = false; - var components = getNormalizedPathComponents(spec, basePath); - if (usage !== "exclude" && components[components.length - 1] === "**") { - continue spec; - } - components[0] = removeTrailingDirectorySeparator(components[0]); - var optionalCount = 0; - for (var _a = 0, components_1 = components; _a < components_1.length; _a++) { - var component = components_1[_a]; - if (component === "**") { - if (hasRecursiveDirectoryWildcard) { - continue spec; - } - subpattern += doubleAsteriskRegexFragment; - hasRecursiveDirectoryWildcard = true; - hasWrittenComponent = true; - } - else { - if (usage === "directories") { - subpattern += "("; - optionalCount++; - } - if (hasWrittenComponent) { - subpattern += ts.directorySeparator; - } - if (usage !== "exclude") { - if (component.charCodeAt(0) === 42) { - subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; - component = component.substr(1); - } - else if (component.charCodeAt(0) === 63) { - subpattern += "[^./]"; - component = component.substr(1); - } - } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); - hasWrittenComponent = true; - } - } - while (optionalCount > 0) { - subpattern += ")?"; - optionalCount--; + var subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter); + if (subPattern === undefined) { + continue; } if (hasWrittenSubpattern) { pattern += "|"; } - pattern += "(" + subpattern + ")"; + pattern += "(" + subPattern + ")"; hasWrittenSubpattern = true; } if (!pattern) { return undefined; } - return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + var terminator = usage === "exclude" ? "($|/)" : "$"; + return "^(" + pattern + ")" + terminator; } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; + function isImplicitGlob(lastPathComponent) { + return !/[.*?]/.test(lastPathComponent); + } + ts.isImplicitGlob = isImplicitGlob; + function getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter) { + var subpattern = ""; + var hasRecursiveDirectoryWildcard = false; + var hasWrittenComponent = false; + var components = getNormalizedPathComponents(spec, basePath); + var lastComponent = lastOrUndefined(components); + if (usage !== "exclude" && lastComponent === "**") { + return undefined; + } + components[0] = removeTrailingDirectorySeparator(components[0]); + if (isImplicitGlob(lastComponent)) { + components.push("**", "*"); + } + var optionalCount = 0; + for (var _i = 0, components_1 = components; _i < components_1.length; _i++) { + var component = components_1[_i]; + if (component === "**") { + if (hasRecursiveDirectoryWildcard) { + return undefined; + } + subpattern += doubleAsteriskRegexFragment; + hasRecursiveDirectoryWildcard = true; + } + else { + if (usage === "directories") { + subpattern += "("; + optionalCount++; + } + if (hasWrittenComponent) { + subpattern += ts.directorySeparator; + } + if (usage !== "exclude") { + if (component.charCodeAt(0) === 42) { + subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; + component = component.substr(1); + } + else if (component.charCodeAt(0) === 63) { + subpattern += "[^./]"; + component = component.substr(1); + } + } + subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + } + hasWrittenComponent = true; + } + while (optionalCount > 0) { + subpattern += ")?"; + optionalCount--; + } + return subpattern; + } function replaceWildCardCharacterFiles(match) { return replaceWildcardCharacter(match, singleAsteriskRegexFragmentFiles); } @@ -1529,25 +1597,30 @@ var ts; for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) { var include = includes_1[_i]; var absolute = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include)); - var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); - var includeBasePath = wildcardOffset < 0 - ? removeTrailingDirectorySeparator(getDirectoryPath(absolute)) - : absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); - includeBasePaths.push(includeBasePath); + includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); - include: for (var i = 0; i < includeBasePaths.length; i++) { - var includeBasePath = includeBasePaths[i]; - for (var j = 0; j < basePaths.length; j++) { - if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) { - continue include; - } + var _loop_1 = function (includeBasePath) { + if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + basePaths.push(includeBasePath); } - basePaths.push(includeBasePath); + }; + for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) { + var includeBasePath = includeBasePaths_1[_a]; + _loop_1(includeBasePath); } } return basePaths; } + function getIncludeBasePath(absolute) { + var wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes); + if (wildcardOffset < 0) { + return !hasExtension(absolute) + ? absolute + : removeTrailingDirectorySeparator(getDirectoryPath(absolute)); + } + return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); + } function ensureScriptKind(fileName, scriptKind) { return (scriptKind || getScriptKindFromFileName(fileName)) || 3; } @@ -1647,10 +1720,6 @@ var ts; return path.substring(0, path.length - extension.length); } ts.removeExtension = removeExtension; - function isJsxOrTsxExtension(ext) { - return ext === ".jsx" || ext === ".tsx"; - } - ts.isJsxOrTsxExtension = isJsxOrTsxExtension; function changeExtension(path, newExtension) { return (removeFileExtension(path) + newExtension); } @@ -1796,6 +1865,30 @@ var ts; return !(pos >= 0); } ts.positionIsSynthesized = positionIsSynthesized; + function extensionIsTypeScript(ext) { + return ext <= ts.Extension.LastTypeScriptExtension; + } + ts.extensionIsTypeScript = extensionIsTypeScript; + function extensionFromPath(path) { + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } + Debug.fail("File " + path + " has unknown extension."); + return ts.Extension.Js; + } + ts.extensionFromPath = extensionFromPath; })(ts || (ts = {})); var ts; (function (ts) { @@ -2090,6 +2183,7 @@ var ts; function getDirectories(path) { return ts.filter(_fs.readdirSync(path), function (dir) { return fileSystemEntryExists(ts.combinePaths(path, dir), 1); }); } + var noOpFileWatcher = { close: ts.noop }; var nodeSystem = { args: process.argv.slice(2), newLine: _os.EOL, @@ -2099,7 +2193,7 @@ var ts; }, readFile: readFile, writeFile: writeFile, - watchFile: function (fileName, callback) { + watchFile: function (fileName, callback, pollingInterval) { if (useNonPollingWatchers) { var watchedFile_1 = watchedFileSet.addFile(fileName, callback); return { @@ -2107,7 +2201,7 @@ var ts; }; } else { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + _fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged); return { close: function () { return _fs.unwatchFile(fileName, fileChanged); } }; @@ -2122,7 +2216,7 @@ var ts; watchDirectory: function (directoryName, callback, recursive) { var options; if (!directoryExists(directoryName)) { - return; + return noOpFileWatcher; } if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; @@ -2319,7 +2413,7 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_parameter_cannot_have_an_initializer_1052", message: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A_set_accessor_cannot_have_rest_parameter_1053", message: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_cannot_have_parameters_1054", message: "A 'get' accessor cannot have parameters." }, - Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_1055", message: "Type '{0}' is not a valid async function return type." }, + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, @@ -2546,14 +2640,14 @@ var ts; Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_of_assignment_expression_2364", message: "Invalid left-hand side of assignment expression." }, + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, @@ -2593,7 +2687,7 @@ var ts; Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: ts.DiagnosticCategory.Error, key: "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", message: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", message: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", message: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_in_statement_2406", message: "Invalid left-hand side in 'for...in' statement." }, + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, @@ -2631,8 +2725,6 @@ var ts; Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", message: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: ts.DiagnosticCategory.Error, key: "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", message: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: ts.DiagnosticCategory.Error, key: "Block_scoped_variable_0_used_before_its_declaration_2448", message: "Block-scoped variable '{0}' used before its declaration." }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property: { code: 2449, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant_or_a_read_only_property_2449", message: "The operand of an increment or decrement operator cannot be a constant or a read-only property." }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Left_hand_side_of_assignment_expression_cannot_be_a_constant_or_a_read_only_property_2450", message: "Left-hand side of assignment expression cannot be a constant or a read-only property." }, Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_block_scoped_variable_0_2451", message: "Cannot redeclare block-scoped variable '{0}'." }, An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: ts.DiagnosticCategory.Error, key: "An_enum_member_cannot_have_a_numeric_name_2452", message: "An enum member cannot have a numeric name." }, The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: ts.DiagnosticCategory.Error, key: "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", message: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, @@ -2644,7 +2736,7 @@ var ts; Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_an_array_destructuring_pattern_2462", message: "A rest element must be last in an array destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2666,9 +2758,7 @@ var ts; Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: { code: 2481, category: ts.DiagnosticCategory.Error, key: "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", message: "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'." }, The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: { code: 2483, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", message: "The left-hand side of a 'for...of' statement cannot use a type annotation." }, Export_declaration_conflicts_with_exported_declaration_of_0: { code: 2484, category: ts.DiagnosticCategory.Error, key: "Export_declaration_conflicts_with_exported_declaration_of_0_2484", message: "Export declaration conflicts with exported declaration of '{0}'" }, - The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2485, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_cannot_be_a_constant_or_a_read_only_property_2485", message: "The left-hand side of a 'for...of' statement cannot be a constant or a read-only property." }, - The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property: { code: 2486, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_constant_or_a_read_only_property_2486", message: "The left-hand side of a 'for...in' statement cannot be a constant or a read-only property." }, - Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: ts.DiagnosticCategory.Error, key: "Invalid_left_hand_side_in_for_of_statement_2487", message: "Invalid left-hand side in 'for...of' statement." }, + The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488", message: "Type must have a '[Symbol.iterator]()' method that returns an iterator." }, An_iterator_must_have_a_next_method: { code: 2489, category: ts.DiagnosticCategory.Error, key: "An_iterator_must_have_a_next_method_2489", message: "An iterator must have a 'next()' method." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, @@ -2715,6 +2805,13 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, + Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, + Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, + Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, + Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property: { code: 2540, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540", message: "Cannot assign to '{0}' because it is a constant or a read-only property." }, + The_target_of_an_assignment_must_be_a_variable_or_a_property_access: { code: 2541, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", message: "The target of an assignment must be a variable or a property access." }, + Index_signature_in_type_0_only_permits_reading: { code: 2542, category: ts.DiagnosticCategory.Error, key: "Index_signature_in_type_0_only_permits_reading_2542", message: "Index signature in type '{0}' only permits reading." }, JSX_element_attributes_type_0_may_not_be_a_union_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", message: "JSX element attributes type '{0}' may not be a union type." }, The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", message: "The return type of a JSX element constructor must return an object type." }, JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", message: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." }, @@ -2738,6 +2835,7 @@ var ts; Cannot_find_name_0_Did_you_mean_the_static_member_1_0: { code: 2662, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662", message: "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?" }, Cannot_find_name_0_Did_you_mean_the_instance_member_this_0: { code: 2663, category: ts.DiagnosticCategory.Error, key: "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663", message: "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?" }, Invalid_module_name_in_augmentation_module_0_cannot_be_found: { code: 2664, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664", message: "Invalid module name in augmentation, module '{0}' cannot be found." }, + Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented: { code: 2665, category: ts.DiagnosticCategory.Error, key: "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665", message: "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented." }, Exports_and_export_assignments_are_not_permitted_in_module_augmentations: { code: 2666, category: ts.DiagnosticCategory.Error, key: "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666", message: "Exports and export assignments are not permitted in module augmentations." }, Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module: { code: 2667, category: ts.DiagnosticCategory.Error, key: "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667", message: "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module." }, export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible: { code: 2668, category: ts.DiagnosticCategory.Error, key: "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668", message: "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible." }, @@ -2769,6 +2867,9 @@ var ts; Namespace_0_has_no_exported_member_1: { code: 2694, category: ts.DiagnosticCategory.Error, key: "Namespace_0_has_no_exported_member_1_2694", message: "Namespace '{0}' has no exported member '{1}'." }, Left_side_of_comma_operator_is_unused_and_has_no_side_effects: { code: 2695, category: ts.DiagnosticCategory.Error, key: "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", message: "Left side of comma operator is unused and has no side effects." }, The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: { code: 2696, category: ts.DiagnosticCategory.Error, key: "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", message: "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?" }, + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, + Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, + Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2868,6 +2969,7 @@ var ts; Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, Substitutions_for_pattern_0_shouldn_t_be_an_empty_array: { code: 5066, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066", message: "Substitutions for pattern '{0}' shouldn't be an empty array." }, + Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name: { code: 5067, category: ts.DiagnosticCategory.Error, key: "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067", message: "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." }, Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: ts.DiagnosticCategory.Message, key: "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003", message: "Specify the location where debugger should locate map files instead of generated locations." }, @@ -2951,7 +3053,7 @@ var ts; File_0_exist_use_it_as_a_name_resolution_result: { code: 6097, category: ts.DiagnosticCategory.Message, key: "File_0_exist_use_it_as_a_name_resolution_result_6097", message: "File '{0}' exist - use it as a name resolution result." }, Loading_module_0_from_node_modules_folder: { code: 6098, category: ts.DiagnosticCategory.Message, key: "Loading_module_0_from_node_modules_folder_6098", message: "Loading module '{0}' from 'node_modules' folder." }, Found_package_json_at_0: { code: 6099, category: ts.DiagnosticCategory.Message, key: "Found_package_json_at_0_6099", message: "Found 'package.json' at '{0}'." }, - package_json_does_not_have_types_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_types_field_6100", message: "'package.json' does not have 'types' field." }, + package_json_does_not_have_a_types_or_main_field: { code: 6100, category: ts.DiagnosticCategory.Message, key: "package_json_does_not_have_a_types_or_main_field_6100", message: "'package.json' does not have a 'types' or 'main' field." }, package_json_has_0_field_1_that_references_2: { code: 6101, category: ts.DiagnosticCategory.Message, key: "package_json_has_0_field_1_that_references_2_6101", message: "'package.json' has '{0}' field '{1}' that references '{2}'." }, Allow_javascript_files_to_be_compiled: { code: 6102, category: ts.DiagnosticCategory.Message, key: "Allow_javascript_files_to_be_compiled_6102", message: "Allow javascript files to be compiled." }, Option_0_should_have_array_of_strings_as_a_value: { code: 6103, category: ts.DiagnosticCategory.Error, key: "Option_0_should_have_array_of_strings_as_a_value_6103", message: "Option '{0}' should have array of strings as a value." }, @@ -2988,11 +3090,16 @@ var ts; Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, - No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'" }, + No_types_specified_in_package_json_so_returning_main_value_of_0: { code: 6137, category: ts.DiagnosticCategory.Message, key: "No_types_specified_in_package_json_so_returning_main_value_of_0_6137", message: "No types specified in 'package.json', so returning 'main' value of '{0}'" }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, + Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, + Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, + Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: { code: 6145, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", message: "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified." }, + Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -3001,7 +3108,8 @@ var ts; Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: ts.DiagnosticCategory.Error, key: "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011", message: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: ts.DiagnosticCategory.Error, key: "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013", message: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number: { code: 7015, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015", message: "Element implicitly has an 'any' type because index expression is not of type 'number'." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Index_signature_of_object_type_implicitly_has_an_any_type_7017", message: "Index signature of object type implicitly has an 'any' type." }, + Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type: { code: 7016, category: ts.DiagnosticCategory.Error, key: "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016", message: "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type." }, + Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature: { code: 7017, category: ts.DiagnosticCategory.Error, key: "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017", message: "Element implicitly has an 'any' type because type '{0}' has no index signature." }, Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: ts.DiagnosticCategory.Error, key: "Object_literal_s_property_0_implicitly_has_an_1_type_7018", message: "Object literal's property '{0}' implicitly has an '{1}' type." }, Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: ts.DiagnosticCategory.Error, key: "Rest_parameter_0_implicitly_has_an_any_type_7019", message: "Rest parameter '{0}' implicitly has an 'any[]' type." }, Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: ts.DiagnosticCategory.Error, key: "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020", message: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, @@ -3058,6 +3166,7 @@ var ts; Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, }; })(ts || (ts = {})); var ts; @@ -3090,7 +3199,7 @@ var ts; "false": 85, "finally": 86, "for": 87, - "from": 137, + "from": 138, "function": 88, "get": 124, "if": 89, @@ -3100,34 +3209,35 @@ var ts; "instanceof": 92, "interface": 108, "is": 125, + "keyof": 126, "let": 109, - "module": 126, - "namespace": 127, - "never": 128, + "module": 127, + "namespace": 128, + "never": 129, "new": 93, "null": 94, - "number": 131, + "number": 132, "package": 110, "private": 111, "protected": 112, "public": 113, - "readonly": 129, - "require": 130, - "global": 138, + "readonly": 130, + "require": 131, + "global": 139, "return": 95, - "set": 132, + "set": 133, "static": 114, - "string": 133, + "string": 134, "super": 96, "switch": 97, - "symbol": 134, + "symbol": 135, "this": 98, "throw": 99, "true": 100, "try": 101, - "type": 135, + "type": 136, "typeof": 102, - "undefined": 136, + "undefined": 137, "var": 103, "void": 104, "while": 105, @@ -3135,7 +3245,7 @@ var ts; "yield": 115, "async": 119, "await": 120, - "of": 139, + "of": 140, "{": 16, "}": 17, "(": 18, @@ -4522,9 +4632,9 @@ var ts; pos++; return token = 22; } - if (isIdentifierStart(ch, 4)) { + if (isIdentifierStart(ch, 5)) { pos++; - while (isIdentifierPart(text.charCodeAt(pos), 4) && pos < end) { + while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } return token = 70; @@ -4683,6 +4793,11 @@ var ts; type: "string", description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, + { + name: "jsxFactory", + type: "string", + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "listFiles", type: "boolean", @@ -4870,6 +4985,7 @@ var ts; "es2015": 2, "es2016": 3, "es2017": 4, + "esnext": 5, }), description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: ts.Diagnostics.VERSION, @@ -5026,7 +5142,8 @@ var ts; "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", }), }, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon @@ -5513,9 +5630,7 @@ var ts; return options; } function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = ts.getBaseFileName(configFileName) === "jsconfig.json" - ? { enableAutoDiscovery: true, include: [], exclude: [] } - : { enableAutoDiscovery: false, include: [], exclude: [] }; + var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); return options; } @@ -5646,14 +5761,13 @@ var ts; var recursiveKeys = []; for (var _i = 0, include_1 = include; _i < include_1.length; _i++) { var file = include_1[_i]; - var name_6 = ts.normalizePath(ts.combinePaths(path, file)); - if (excludeRegex && excludeRegex.test(name_6)) { + var spec = ts.normalizePath(ts.combinePaths(path, file)); + if (excludeRegex && excludeRegex.test(spec)) { continue; } - var match = wildcardDirectoryPattern.exec(name_6); + var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames); if (match) { - var key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); - var flags = watchRecursivePattern.test(name_6) ? 1 : 0; + var key = match.key, flags = match.flags; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; @@ -5674,6 +5788,19 @@ var ts; } return wildcardDirectories; } + function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) { + var match = wildcardDirectoryPattern.exec(spec); + if (match) { + return { + key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(), + flags: watchRecursivePattern.test(spec) ? 1 : 0 + }; + } + if (ts.isImplicitGlob(spec)) { + return { key: spec, flags: 1 }; + } + return undefined; + } function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { var extensionPriority = ts.getExtensionPriority(file, extensions); var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority); @@ -5742,7 +5869,7 @@ var ts; mergeTypings(typingOptions.include); exclude = typingOptions.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); - if (projectRootPath !== undefined) { + if (projectRootPath) { possibleSearchDirs.push(projectRootPath); } searchDirs = ts.deduplicate(possibleSearchDirs); @@ -5765,9 +5892,9 @@ var ts; } } } - for (var name_7 in packageNameToTypingLocation) { - if (name_7 in inferredTypings && !inferredTypings[name_7]) { - inferredTypings[name_7] = packageNameToTypingLocation[name_7]; + for (var name_6 in packageNameToTypingLocation) { + if (name_6 in inferredTypings && !inferredTypings[name_6]) { + inferredTypings[name_6] = packageNameToTypingLocation[name_6]; } } for (var _b = 0, exclude_1 = exclude; _b < exclude_1.length; _b++) { @@ -5903,24 +6030,50 @@ var ts; return compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; - function createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations) { - return { resolvedModule: resolvedFileName ? { resolvedFileName: resolvedFileName, isExternalLibraryImport: isExternalLibraryImport } : undefined, failedLookupLocations: failedLookupLocations }; + function resolvedTypeScriptOnly(resolved) { + if (!resolved) { + return undefined; + } + ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); + return resolved.path; + } + function resolvedFromAnyFile(path) { + return { path: path, extension: ts.extensionFromPath(path) }; + } + function resolvedModuleFromResolved(_a, isExternalLibraryImport) { + var path = _a.path, extension = _a.extension; + return { resolvedFileName: path, extension: extension, isExternalLibraryImport: isExternalLibraryImport }; + } + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations: failedLookupLocations }; } - ts.createResolvedModule = createResolvedModule; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } - function tryReadTypesSection(packageJsonPath, baseDirectory, state) { + function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); + switch (extensions) { + case 2: + case 0: + return tryReadFromField("typings") || tryReadFromField("types"); + case 1: + if (typeof jsonContent.main === "string") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); + } + return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); + } + return undefined; + } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { var typesFile = jsonContent[fieldName]; if (typeof typesFile === "string") { - var typesFilePath_1 = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); + var typesFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, typesFile)); if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath_1); + trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); } - return typesFilePath_1; + return typesFilePath; } else { if (state.traceEnabled) { @@ -5929,18 +6082,6 @@ var ts; } } } - var typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); - if (typesFilePath) { - return typesFilePath; - } - if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_but_allowJs_is_set_so_returning_main_value_of_0, jsonContent.main); - } - var mainFilePath = ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - return mainFilePath; - } - return undefined; } function readJson(path, host) { try { @@ -5951,7 +6092,6 @@ var ts; return {}; } } - var typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options, host) { if (options.typeRoots) { return options.typeRoots; @@ -5990,7 +6130,6 @@ var ts; var moduleResolutionState = { compilerOptions: options, host: host, - skipTsx: true, traceEnabled: traceEnabled }; var typeRoots = getEffectiveTypeRoots(options, host); @@ -6017,18 +6156,17 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } - var primarySearchPaths = typeRoots; - for (var _i = 0, primarySearchPaths_1 = primarySearchPaths; _i < primarySearchPaths_1.length; _i++) { - var typeRoot = primarySearchPaths_1[_i]; + for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { + var typeRoot = typeRoots_1[_i]; var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName); var candidateDirectory = ts.getDirectoryPath(candidate); - var resolvedFile_1 = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState); - if (resolvedFile_1) { + var resolved = resolvedTypeScriptOnly(loadNodeModuleFromDirectory(2, candidate, failedLookupLocations, !directoryProbablyExists(candidateDirectory, host), moduleResolutionState)); + if (resolved) { if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile_1, true); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true); } return { - resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile_1 }, + resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved }, failedLookupLocations: failedLookupLocations }; } @@ -6040,15 +6178,12 @@ var ts; } } var resolvedFile; - var initialLocationForSecondaryLookup; - if (containingFile) { - initialLocationForSecondaryLookup = ts.getDirectoryPath(containingFile); - } + var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false); + resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(2, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, false)); if (traceEnabled) { if (resolvedFile) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false); @@ -6064,9 +6199,7 @@ var ts; } } return { - resolvedTypeReferenceDirective: resolvedFile - ? { primary: false, resolvedFileName: resolvedFile } - : undefined, + resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined, failedLookupLocations: failedLookupLocations }; } @@ -6079,8 +6212,8 @@ var ts; if (host.directoryExists && host.getDirectories) { var typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { - for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { - var root = typeRoots_1[_i]; + for (var _i = 0, typeRoots_2 = typeRoots; _i < typeRoots_2.length; _i++) { + var root = typeRoots_2[_i]; if (host.directoryExists(root)) { for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) { var typeDirectivePath = _b[_a]; @@ -6135,15 +6268,15 @@ var ts; return result; } ts.resolveModuleName = resolveModuleName; - function tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (moduleHasNonRelativeName(moduleName)) { - return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state); } else { - return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state); + return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state); } } - function tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state) { if (!state.compilerOptions.rootDirs) { return undefined; } @@ -6177,7 +6310,7 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); + var resolvedFileName = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state); if (resolvedFileName) { return resolvedFileName; } @@ -6194,7 +6327,7 @@ var ts; trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1); } var baseDirectory = ts.getDirectoryPath(candidate_1); - var resolvedFileName_1 = loader(candidate_1, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); + var resolvedFileName_1 = loader(extensions, candidate_1, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state); if (resolvedFileName_1) { return resolvedFileName_1; } @@ -6205,7 +6338,7 @@ var ts; } return undefined; } - function tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state) { + function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, failedLookupLocations, state) { if (!state.compilerOptions.baseUrl) { return undefined; } @@ -6232,9 +6365,9 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path); } - var resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); - if (resolvedFileName) { - return resolvedFileName; + var resolved = loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + if (resolved) { + return resolved; } } return undefined; @@ -6244,53 +6377,63 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate); } - return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); + return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host) { var containingDirectory = ts.getDirectoryPath(containingFile); - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: false }; - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, supportedExtensions, state); - var isExternalLibraryImport = false; - if (!resolvedFileName) { + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var result = tryResolve(0) || tryResolve(1); + if (result) { + var resolved = result.resolved, isExternalLibraryImport = result.isExternalLibraryImport; + return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations); + } + return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + function tryResolve(extensions) { + var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, nodeLoadModuleByRelativeName, failedLookupLocations, state); + if (resolved) { + return { resolved: resolved, isExternalLibraryImport: false }; + } if (moduleHasNonRelativeName(moduleName)) { if (traceEnabled) { trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder, moduleName); } - resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state, false); - isExternalLibraryImport = resolvedFileName !== undefined; + var resolved_1 = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state, false); + return resolved_1 && { resolved: resolved_1, isExternalLibraryImport: true }; } else { var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, false, state); + var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, false, state); + return resolved_2 && { resolved: resolved_2, isExternalLibraryImport: false }; } } - if (resolvedFileName && host.realpath) { - var originalFileName = resolvedFileName; - resolvedFileName = ts.normalizePath(host.realpath(resolvedFileName)); - if (traceEnabled) { - trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, originalFileName, resolvedFileName); - } - } - return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state) { + function resolvedWithRealpath(resolved, host, traceEnabled) { + if (!host.realpath) { + return resolved; + } + var real = ts.normalizePath(host.realpath(resolved.path)); + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real); + } + return { path: real, extension: resolved.extension }; + } + function nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - var resolvedFileName = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); - return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); + var resolvedFromFile = !ts.pathEndsWithDirectorySeparator(candidate) && loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); + return resolvedFromFile || loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); } function directoryProbablyExists(directoryName, host) { return !host.directoryExists || host.directoryExists(directoryName); } ts.directoryProbablyExists = directoryProbablyExists; - function loadModuleFromFile(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -6300,19 +6443,28 @@ var ts; var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocations, onlyRecordFailures, state); } } - function tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state) { if (!onlyRecordFailures) { var directory = ts.getDirectoryPath(candidate); if (directory) { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return ts.forEach(extensions, function (ext) { - return !(state.skipTsx && ts.isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state); - }); + switch (extensions) { + case 2: + return tryExtension(".d.ts", ts.Extension.Dts); + case 0: + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); + case 1: + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); + } + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); + return path && { path: path, extension: extension }; + } } function tryFile(fileName, failedLookupLocation, onlyRecordFailures, state) { if (!onlyRecordFailures && state.host.fileExists(fileName)) { @@ -6336,18 +6488,21 @@ var ts; if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - var typesFile = tryReadTypesSection(packageJsonPath, candidate, state); + var typesFile = tryReadTypesSection(extensions, packageJsonPath, candidate, state); if (typesFile) { var onlyRecordFailures_1 = !directoryProbablyExists(ts.getDirectoryPath(typesFile), state.host); - var result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state) || - tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures_1, state); - if (result) { - return result; + var fromFile = tryFile(typesFile, failedLookupLocation, onlyRecordFailures_1, state); + if (fromFile) { + return resolvedFromAnyFile(fromFile); + } + var x = tryAddingExtensions(typesFile, 0, failedLookupLocation, onlyRecordFailures_1, state); + if (x) { + return x; } } else { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.package_json_does_not_have_types_field); + trace(state.host, ts.Diagnostics.package_json_does_not_have_a_types_or_main_field); } } } @@ -6357,85 +6512,76 @@ var ts; } failedLookupLocation.push(packageJsonPath); } - return loadModuleFromFile(ts.combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, state); } function pathToPackageJson(directory) { return ts.combinePaths(directory, "package.json"); } - function loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) { + function loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - var supportedExtensions = ts.getSupportedExtensions(state.compilerOptions); - var result = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } - result = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); - if (result) { - return result; - } + return loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); } - function loadModuleFromNodeModules(moduleName, directory, failedLookupLocations, state, checkOneLevel) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, false); + function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel) { + return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, false); } - ts.loadModuleFromNodeModules = loadModuleFromNodeModules; function loadModuleFromNodeModulesAtTypes(moduleName, directory, failedLookupLocations, state) { - return loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, false, true); + return loadModuleFromNodeModulesWorker(0, moduleName, directory, failedLookupLocations, state, false, true); } - function loadModuleFromNodeModulesWorker(moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { + function loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, checkOneLevel, typesOnly) { directory = ts.normalizeSlashes(directory); while (true) { - var baseName = ts.getBaseFileName(directory); - if (baseName !== "node_modules") { - var packageResult = void 0; - if (!typesOnly) { - packageResult = loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state); - if (packageResult && ts.hasTypeScriptFileExtension(packageResult)) { - return packageResult; - } - } - var typesResult = loadModuleFromNodeModulesFolder(ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); - if (typesResult || packageResult) { - return typesResult || packageResult; + if (ts.getBaseFileName(directory) !== "node_modules") { + var resolved = tryInDirectory(); + if (resolved) { + return resolved; } } var parentPath = ts.getDirectoryPath(directory); if (parentPath === directory || checkOneLevel) { - break; + return undefined; } directory = parentPath; } - return undefined; + function tryInDirectory() { + var packageResult = typesOnly ? undefined : loadModuleFromNodeModulesFolder(extensions, moduleName, directory, failedLookupLocations, state); + return packageResult || loadModuleFromNodeModulesFolder(extensions, ts.combinePaths("@types", moduleName), directory, failedLookupLocations, state); + } } function classicNameResolver(moduleName, containingFile, compilerOptions, host) { var traceEnabled = isTraceEnabled(compilerOptions, host); - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, skipTsx: !compilerOptions.jsx }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; var failedLookupLocations = []; - var supportedExtensions = ts.getSupportedExtensions(compilerOptions); var containingDirectory = ts.getDirectoryPath(containingFile); - var resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state); - if (resolvedFileName) { - return createResolvedModule(resolvedFileName, false, failedLookupLocations); + var resolved = tryResolve(0) || tryResolve(1); + return createResolvedModuleWithFailedLookupLocations(resolved, false, failedLookupLocations); + function tryResolve(extensions) { + var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + if (moduleHasNonRelativeName(moduleName)) { + var resolved_3 = loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state); + if (resolved_3) { + return resolved_3; + } + if (extensions === 0) { + return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); + } + } + else { + var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); + return loadModuleFromFile(extensions, candidate, failedLookupLocations, false, state); + } } - var referencedSourceFile; - if (moduleHasNonRelativeName(moduleName)) { - referencedSourceFile = referencedSourceFile = loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) || - loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); - } - else { - var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - referencedSourceFile = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, false, state); - } - return referencedSourceFile - ? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations: failedLookupLocations } - : { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; } ts.classicNameResolver = classicNameResolver; - function loadModuleFromAncestorDirectories(moduleName, containingDirectory, supportedExtensions, failedLookupLocations, state) { + function loadModuleFromAncestorDirectories(extensions, moduleName, containingDirectory, failedLookupLocations, state) { while (true) { var searchName = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName)); - var referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, false, state); + var referencedSourceFile = loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state); if (referencedSourceFile) { return referencedSourceFile; } @@ -6446,6 +6592,18 @@ var ts; containingDirectory = parentPath; } } + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + var traceEnabled = isTraceEnabled(compilerOptions, host); + if (traceEnabled) { + trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); + } + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled }; + var failedLookupLocations = []; + var resolved = loadModuleFromNodeModules(0, moduleName, globalCache, failedLookupLocations, state, true) || + loadModuleFromNodeModules(1, moduleName, globalCache, failedLookupLocations, state, true); + return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations); + } + ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; })(ts || (ts = {})); var ts; (function (ts) { @@ -6461,6 +6619,7 @@ var ts; var result = ts.resolveModuleName(packageName, ts.combinePaths(cachePath, "index.d.ts"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, installTypingHost); return result.resolvedModule && result.resolvedModule.resolvedFileName; } + var PackageNameValidationResult; (function (PackageNameValidationResult) { PackageNameValidationResult[PackageNameValidationResult["Ok"] = 0] = "Ok"; PackageNameValidationResult[PackageNameValidationResult["ScopedPackagesNotSupported"] = 1] = "ScopedPackagesNotSupported"; @@ -6469,8 +6628,7 @@ var ts; PackageNameValidationResult[PackageNameValidationResult["NameStartsWithDot"] = 4] = "NameStartsWithDot"; PackageNameValidationResult[PackageNameValidationResult["NameStartsWithUnderscore"] = 5] = "NameStartsWithUnderscore"; PackageNameValidationResult[PackageNameValidationResult["NameContainsNonURISafeCharacters"] = 6] = "NameContainsNonURISafeCharacters"; - })(typingsInstaller.PackageNameValidationResult || (typingsInstaller.PackageNameValidationResult = {})); - var PackageNameValidationResult = typingsInstaller.PackageNameValidationResult; + })(PackageNameValidationResult = typingsInstaller.PackageNameValidationResult || (typingsInstaller.PackageNameValidationResult = {})); typingsInstaller.MaxPackageNameLength = 214; function validatePackageName(packageName) { if (!packageName) { @@ -6752,7 +6910,7 @@ var ts; _this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate }); isInvoked = true; } - }); + }, 2000); watchers.push(w); } this.projectWatchers[projectName] = watchers; @@ -6773,7 +6931,7 @@ var ts; }; TypingsInstaller.prototype.executeWithThrottling = function () { var _this = this; - var _loop_1 = function () { + var _loop_2 = function () { this_1.inFlightRequestCount++; var request = this_1.pendingRunRequests.pop(); this_1.installWorker(request.requestId, request.args, request.cwd, function (ok) { @@ -6784,7 +6942,7 @@ var ts; }; var this_1 = this; while (this.inFlightRequestCount < this.throttleLimit && this.pendingRunRequests.length) { - _loop_1(); + _loop_2(); } }; return TypingsInstaller;